Request for a new library routine RemoveURLPart()

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Request for a new library routine RemoveURLPart()

Post 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?
Anthony Jordan
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Request for a new library routine RemoveURLPart()

Post 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.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Request for a new library routine RemoveURLPart()

Post 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?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Re: Request for a new library routine RemoveURLPart()

Post 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
Anthony Jordan
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: Request for a new library routine RemoveURLPart()

Post 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?
User avatar
kenmo
Addict
Addict
Posts: 2033
Joined: Tue Dec 23, 2003 3:54 am

Re: Request for a new library routine RemoveURLPart()

Post 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.
Post Reply