@@ -236,19 +236,27 @@ } - (OFString *)stringByStandardizingPath { void *pool = objc_autoreleasePoolPush(); - OFArray OF_GENERIC(OFString *) *components = [self pathComponents]; + OFArray OF_GENERIC(OFString *) *components; OFMutableArray OF_GENERIC(OFString *) *array; OFString *ret; - bool done = false, endsWithEmpty; + bool done = false; + + if ([self length] == 0) + return @""; + + components = [self pathComponents]; + + if ([components count] == 1) { + objc_autoreleasePoolPop(pool); + return [[self copy] autorelease]; + } array = [[components mutableCopy] autorelease]; - endsWithEmpty = [[array lastObject] isEqual: @""]; - while (!done) { size_t length = [array count]; done = true; @@ -274,11 +282,11 @@ break; } } } - if (endsWithEmpty) + if ([self hasSuffix: @"\\"] || [self hasSuffix: @"/"]) [array addObject: @""]; ret = [[array componentsJoinedByString: @"\\"] retain]; objc_autoreleasePoolPop(pool);