Page 1 of 1

Request for a new library routine RemoveURLPart()

Posted: Sun Apr 08, 2012 5:50 pm
by akj
I have found a need for a function RemoveURLPart() which is simialr to GetURLPart() and can be described thus:

RemoveURLPart()

Syntax
Result$ = URLPart(URL$, Parameter$)

Description
Remove a specific field of the given URL$. This can be a named parameter or another field within the URL.

Examples
URL$ = "purebasic.com:80/index.php3?test=1&ok=2"

Debug RemoveURLPart(URL$, "Test")
gives "purebasic.com:80/index.php3?ok=2"
Debug RemoveURLPart(URL$, #PB_URL_Parameters)
gives "purebasic.com:80/index.php3
Debug RemoveURLPart(URL$, #PB_URL_Port)
gives "purebasic.com/index.php3?test=1&ok=2"
Debug RemoveURLPart(URL$, #PB_URL_Path)
gives "purebasic.com:80"
as the parameters are useless without the path

Could this please be implemented?

Re: Request for a new library routine RemoveURLPart()

Posted: Sun Apr 08, 2012 6:41 pm
by jassing
Would be easy enough to make using existing functions. I don't see the wide appeal for having it as a base function.

Re: Request for a new library routine RemoveURLPart()

Posted: Sun Apr 08, 2012 9:13 pm
by IdeasVacuum
Sorry akj, I tend agree with jassing on this one. I can't see a great demand for this function - but you could persuade otherwise if you can give compelling reasons. It would be more elegant than using a home-grown macro/procedure, but why would we all want it in the first place?

Re: Request for a new library routine RemoveURLPart()

Posted: Wed Apr 11, 2012 2:12 am
by akj
Yes, I guess I agree your comments and I withdraw my request, but ...

It would be nice (for me) if SetURLPart() did this when supplied with a null parameter, but instead it returns bad results.
For example:

Code: Select all

URL$ = "http://user:pass@www.purebasic.com:80/index.php3

URL$ = SetURLPart(URL$, #PB_URL_Port, "")

Debug URL$ ; Bad result of http://user:pass@www.purebasic.com:/index.php3 (notice the unwanted colon after .com)

URL$ = SetURLPart(URL$, #PB_URL_Protocol, "")

Debug URL$ ; Bad result of ://user:pass@www.purebasic.com:/index.php3

Re: Request for a new library routine RemoveURLPart()

Posted: Wed Apr 11, 2012 3:01 am
by jassing
It's easy enough to write your own "removeurlpart" function -- why not go that route instead of trying to force functions to do something else?

Re: Request for a new library routine RemoveURLPart()

Posted: Wed Apr 11, 2012 4:08 am
by kenmo
The same arguments could be made for many PB commands, including SetURLPart() itself.

I think this is a perfectly legitimate feature request. Not a high priority, but I would be glad to see it pop up on the "Added" list in a future version.