mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-04-24 04:46:01 +08:00
Rework path based response descriptor matching and expand test coverage. Eliminate path normalization. fixes #987
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user