Under IOS, I wish to identify pairs of NSURL
s that are either identical or differ slightly but refer to the same destination. For instance http://google.com
vs http://google.com/
.
isEquals
reports those NSURLs as diferent. Nor can I find a way to obtain a 'canonical' or 'normalized' form of an NSURL to compare those forms instead.
NSURL *a = [NSURL URLWithString:@"http://google.com"];
NSURL *b = [NSURL URLWithString:@"http://google.com/"];
if([a isEqual:b]) {
NSLog(@"Same"); // Not run
}
if([[a absoluteURL] isEqual:[b absoluteURL]]) {
NSLog(@"Same"); // Still not run
}
if([[a URLByStandardizingPath] isEqual:[b URLByStandardizingPath]]) {
NSLog(@"Same"); // Still not run
}
How can I compare two NSURLs while ignoring string differences that do not affect the intent of the URL?