Rework path based response descriptor matching and expand test coverage. Eliminate path normalization. fixes #987

This commit is contained in:
Blake Watters
2012-10-14 13:46:38 -04:00
parent 4a7ed3cbd3
commit f3ece00743
13 changed files with 300 additions and 109 deletions

View File

@@ -22,7 +22,6 @@
#import "SOCKit.h"
#import "RKLog.h"
#import "RKDictionaryUtilities.h"
#import "RKPathUtilities.h"
static NSString *RKEncodeURLString(NSString *unencodedString);
extern NSDictionary *RKQueryParametersFromStringWithEncoding(NSString *string, NSStringEncoding stringEncoding);
@@ -77,12 +76,6 @@ static NSString *RKEncodeURLString(NSString *unencodedString)
return matcher;
}
// Normalize our root path for matching cleanly with SOCKit
- (void)setRootPath:(NSString *)rootPath
{
_rootPath = RKPathNormalize(rootPath);
}
- (BOOL)matches
{
NSAssert((self.socPattern != NULL && self.rootPath != NULL), @"Matcher is insufficiently configured. Before attempting pattern matching, you must provide a path string and a pattern to match it against.");
@@ -145,10 +138,11 @@ static NSString *RKEncodeURLString(NSString *unencodedString)
NSAssert(self.socPattern != NULL, @"Matcher has no established pattern. Instantiate it using pathMatcherWithPattern: before calling pathFromObject:");
NSAssert(object != NULL, @"Object provided is invalid; cannot create a path from a NULL object");
NSString *(^encoderBlock)(NSString *interpolatedString) = nil;
if (addEscapes)
if (addEscapes) {
encoderBlock = ^NSString *(NSString *interpolatedString) {
return RKEncodeURLString(interpolatedString);
};
}
NSString *path = [self.socPattern stringFromObject:object withBlock:encoderBlock];
return path;
}