Fix issue with exact substring path patterns failing to match

This commit is contained in:
Blake Watters
2012-10-04 22:26:43 -04:00
parent 25e1f9ed4d
commit 4060441abb
5 changed files with 128 additions and 34 deletions

View File

@@ -69,6 +69,11 @@ static BOOL RKURLIsRelativeToURL(NSURL *sourceURL, NSURL *baseURL)
return [[sourceURL absoluteString] hasPrefix:[baseURL absoluteString]];
}
static BOOL RKPathPatternIsNilOrAbsolute(NSString *pathPattern)
{
return pathPattern == nil || [pathPattern characterAtIndex:0] == '/';
}
@interface RKResponseDescriptor ()
@property (nonatomic, strong, readwrite) RKMapping *mapping;
@property (nonatomic, copy, readwrite) NSString *pathPattern;
@@ -84,7 +89,7 @@ static BOOL RKURLIsRelativeToURL(NSURL *sourceURL, NSURL *baseURL)
statusCodes:(NSIndexSet *)statusCodes
{
NSParameterAssert(mapping);
NSAssert(RKPathPatternIsNilOrAbsolute(pathPattern), @"The given path pattern must be absolute as it will be evaluated against a complete path segment.");
RKResponseDescriptor *mappingDescriptor = [self new];
mappingDescriptor.mapping = mapping;
mappingDescriptor.pathPattern = pathPattern;