@@ -20,12 +20,12 @@ #include "config.h" #import "OFString+PathAdditions.h" #import "OFArray.h" -#import "OFFileURLHandler.h" -#import "OFURL.h" +#import "OFFileURIHandler.h" +#import "OFURI.h" #import "OFInvalidFormatException.h" #import "OFOutOfRangeException.h" int _OFString_PathAdditions_reference; @@ -201,11 +201,11 @@ objc_autoreleasePoolPop(pool); return @"."; } components = [components objectsInRange: - OFRangeMake(0, components.count - 1)]; + OFMakeRange(0, components.count - 1)]; ret = [OFString pathWithComponents: components]; [ret retain]; objc_autoreleasePoolPop(pool); return [ret autorelease]; @@ -286,11 +286,11 @@ ![parent hasSuffix: @":"] && ![parent hasSuffix: @":\\"] && ![parent hasSuffix: @"://"] && (![parent hasPrefix: @"\\"] || i != 1)) { [array removeObjectsInRange: - OFRangeMake(i - 1, 2)]; + OFMakeRange(i - 1, 2)]; done = false; break; } } @@ -341,38 +341,40 @@ } - (bool)of_isDirectoryPath { return ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"] || - [OFFileURLHandler of_directoryExistsAtPath: self]); + [OFFileURIHandler of_directoryExistsAtPath: self]); } -- (OFString *)of_pathToURLPathWithURLEncodedHost: (OFString **)URLEncodedHost +- (OFString *)of_pathToURIPathWithPercentEncodedHost: + (OFString **)percentEncodedHost { OFString *path = self; if ([path hasPrefix: @"\\\\"]) { OFArray *components = path.pathComponents; if (components.count < 2) @throw [OFInvalidFormatException exception]; - *URLEncodedHost = [[components objectAtIndex: 1] - stringByURLEncodingWithAllowedCharacters: - [OFCharacterSet URLHostAllowedCharacterSet]]; + *percentEncodedHost = [[components objectAtIndex: 1] + stringByAddingPercentEncodingWithAllowedCharacters: + [OFCharacterSet URIHostAllowedCharacterSet]]; path = [OFString pathWithComponents: [components - objectsInRange: OFRangeMake(2, components.count - 2)]]; + objectsInRange: OFMakeRange(2, components.count - 2)]]; } path = [path stringByReplacingOccurrencesOfString: @"\\" withString: @"/"]; - path = [path stringByPrependingString: @"/"]; + path = [@"/" stringByAppendingString: path]; return path; } -- (OFString *)of_URLPathToPathWithURLEncodedHost: (OFString *)URLEncodedHost +- (OFString *)of_URIPathToPathWithPercentEncodedHost: + (OFString *)percentEncodedHost { OFString *path = self; if (path.length > 1 && [path hasSuffix: @"/"] && ![path hasSuffix: @":/"]) @@ -380,12 +382,13 @@ path = [path substringFromIndex: 1]; path = [path stringByReplacingOccurrencesOfString: @"/" withString: @"\\"]; - if (URLEncodedHost != nil) { - OFString *host = [URLEncodedHost stringByURLDecoding]; + if (percentEncodedHost != nil) { + OFString *host = [percentEncodedHost + stringByRemovingPercentEncoding]; if (path.length == 0) path = [OFString stringWithFormat: @"\\\\%@", host]; else path = [OFString stringWithFormat: @"\\\\%@\\%@", @@ -393,11 +396,11 @@ } return path; } -- (OFString *)of_pathComponentToURLPathComponent +- (OFString *)of_pathComponentToURIPathComponent { return [self stringByReplacingOccurrencesOfString: @"\\" withString: @"/"]; } @end