discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Strings, URL and path manipulation


From: Ivan Vučica
Subject: Re: Strings, URL and path manipulation
Date: Thu, 9 Aug 2012 11:44:45 +0200

Looks like it works correctly (although I'd swear it shouldn't be normalizing 
the path as described, and that I've used it on strings with URLs). 

Test code:
NSLog(@"%@", 
[@"http://cs13-api.salesforce.com/services/Soap/u/25.0/00DW00000012fxX"; 
stringByDeletingLastPathComponent]);

OS X output:
2012-08-09 11:32:55.066 test3[2832:707] 
http:/cs13-api.salesforce.com/services/Soap/u/25.0

Why not find last slash and simply "substringToIndex:"? The only trouble arises 
if there is a query string, in which case you'd look up the first question 
mark, strip everything after it (including it), and then find the last slash. 

Or look up first two slashes, and strip everything before them (including 
them), so you get the protocol prefix and everything-but-protocol-prefix. Then 
use stringByDeletingLastPathComponent on everything-but-protocol-prefix. 
Finally append the result to the protocol prefix and you're done. 

On 9. 8. 2012., at 11:21, Riccardo Mottola <riccardo.mottola@libero.it> wrote:

> Hi,
> 
> do you think using path component manipulation methods should work with URLs? 
> I'd expect them to, since the two things are so closely related. I did not 
> check on the mac, the core I am running is gnustep only and I use my mac less 
> and less.
> 
> Example:
> 
> I try: serviceUrl = [[dbs serverUrl] stringByDeletingLastPathComponent];
> 
> serverUrl http://cs13-api.salesforce.com/services/Soap/u/25.0/00DW00000012fxX
> service URL: http:/cs13-api.salesforce.com/services/Soap/u/25.0
> 
> as you may see the "http://"; lost one slash: i suppose it is being 
> interpreted as path and got normalized, removing the //.
> 
> Is that correct or not? Or should I convert the string to a NSURL, use the 
> function as "URLByDeletingPathExtension" and similar and then getting the URL 
> String back? Those are 10.6 methods and since I plan a port to mac 10.4/10.5 
> I'd like to avoid them.
> 
> Riccardo
> 
> _______________________________________________
> Discuss-gnustep mailing list
> Discuss-gnustep@gnu.org
> https://lists.gnu.org/mailman/listinfo/discuss-gnustep

--
Ivan Vučica
ivan@vucica.net - http://ivan.vucica.net/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]