Permalink
Browse files

String comparison is unnecessary if lengths don't match.

  • Loading branch information...
1 parent 70aadff commit 2ca7571ae0603c8b63cee820aea2e9aace7febea @mikeabdullah mikeabdullah committed Aug 27, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 KSPathUtilities.m
View
@@ -183,9 +183,13 @@ - (NSString *)ks_pathRelativeToDirectory:(NSString *)dirPath
if (componentRange.length > 0)
{
// Ignore components which just specify current directory
- if ([dirPath compare:@"." options:NSLiteralSearch range:componentRange] != NSOrderedSame)
+ if (componentRange.length > 1 || [dirPath compare:@"." options:NSLiteralSearch range:componentRange] != NSOrderedSame)
{
- NSAssert([dirPath compare:@".." options:NSLiteralSearch range:componentRange] != NSOrderedSame, @".. unsupported");
+ if (componentRange.length == 2)
+ {
+ NSAssert([dirPath compare:@".." options:NSLiteralSearch range:componentRange] != NSOrderedSame, @".. unsupported");
+ }
+
if ([result length]) [result appendString:@"/"];
[result appendString:@".."];
}

0 comments on commit 2ca7571

Please sign in to comment.