So the end result here is that if you need to remove the last path component of a URL and stand a chance of being passed in one ending in two or more slashes you’re kinda stuck.
I’ve always thought it a good idea to standardize paths and URLs, to get rid of any . or .. components. Otherwise, trying to get the filename or the container URL may give an unexpected result. But this example shows that sometimes even that isn’t enough.
NSURLs are better than
NSStrings, but in my view Cocoa still doesn’t handle file stuff properly.
Stay up-to-date by subscribing to the Comments RSS Feed for this post.