When you have a filesystem path, you can have a ".." removed (and the previous path component removed as well) by using the stringByResolvingSymlinksInPath selector. How can I achieve the same thing for a URL? For example I start out with, say:
www.example.com/themes/themeA/../common/assetA.png
Which I need converted to:
www.example.com/themes/common/assetA.png
                For a URL use the NSURL method:
- (NSURL *)standardizedURL
Returns a new URL that points to the same resource as the original URL and is an absolute path.
Example:
NSString *s  = @"www.example.com/themes/themeA/../common/assetA.png";
NSURL    *u  = [NSURL URLWithString:s];
NSURL    *su = [u standardizedURL];
NSLog(@"su: %@", su);
NSLog output:
su: www.example.com/themes/common/assetA.png
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With