@@ -23,11 +23,12 @@ #import "OFURL+Private.h" #import "OFInvalidFormatException.h" @implementation OFMutableURL -@dynamic scheme, host, port, user, password, path, parameters, query, fragment; +@dynamic scheme, host, port, user, password, path, pathComponents, parameters; +@dynamic query, fragment; + (instancetype)URL { return [[[self alloc] init] autorelease]; } @@ -76,10 +77,30 @@ { OFString *old = _path; _path = [path copy]; [old release]; } + +- (void)setPathComponents: (OFArray *)components +{ + void *pool = objc_autoreleasePoolPush(); + + if (components == nil) { + [self setPath: nil]; + return; + } + + if ([components count] == 0) + @throw [OFInvalidFormatException exception]; + + if ([[components firstObject] length] != 0) + @throw [OFInvalidFormatException exception]; + + [self setPath: [components componentsJoinedByString: @"/"]]; + + objc_autoreleasePoolPop(pool); +} - (void)setParameters: (OFString *)parameters { OFString *old = _parameters; _parameters = [parameters copy]; @@ -98,30 +119,10 @@ OFString *old = _fragment; _fragment = [fragment copy]; [old release]; } -- (void)setPathComponents: (OFArray *)components -{ - void *pool = objc_autoreleasePoolPush(); - - if (components == nil) { - [self setPath: nil]; - return; - } - - if ([components count] == 0) - @throw [OFInvalidFormatException exception]; - - if ([[components firstObject] length] != 0) - @throw [OFInvalidFormatException exception]; - - [self setPath: [components componentsJoinedByString: @"/"]]; - - objc_autoreleasePoolPop(pool); -} - - (id)copy { OFMutableURL *copy = [self mutableCopy]; [copy makeImmutable];