[Issue #72] More fixes to construction of URL from relative path, preventing scheme from incorrectly changing :// to :/

This commit is contained in:
Mattt Thompson 2011-10-17 14:35:56 -05:00
parent 68ef25cb7c
commit 3040aafee9

View File

@ -82,11 +82,12 @@ static NSString * AFBase64EncodedStringFromString(NSString *string) {
}
static NSURL * AFURLWithPathRelativeToURL(NSString *path, NSURL *baseURL) {
NSString *URLString = [[baseURL absoluteString] stringByAppendingPathComponent:path];
NSURL *url = [baseURL URLByAppendingPathComponent:[path stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"/"]]];
NSString *URLString = [url absoluteString];
if ([path hasSuffix:@"/"]) {
URLString = [URLString stringByAppendingString:@"/"];
}
return [NSURL URLWithString:URLString];
}