mirror of
https://github.com/zhigang1992/RestKit.git
synced 2026-05-13 03:29:45 +08:00
Unescape URL metadata mapping parameters if route required parameter escaping
This commit is contained in:
committed by
Blake Watters
parent
e805bbc41e
commit
7f5b0fec97
@@ -140,7 +140,14 @@ static NSString *RKEncodeURLString(NSString *unencodedString)
|
||||
}
|
||||
NSString *path = [self.socPattern stringFromObject:object withBlock:encoderBlock];
|
||||
if (interpolatedParameters) {
|
||||
*interpolatedParameters = [self.socPattern parameterDictionaryFromSourceString:path];
|
||||
NSMutableDictionary *parsedParameters = [[self.socPattern parameterDictionaryFromSourceString:path] mutableCopy];
|
||||
if (addEscapes) {
|
||||
for (NSString *key in [parsedParameters allKeys]) {
|
||||
NSString *unescapedParameter = [[parsedParameters objectForKey:key] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
[parsedParameters setValue:unescapedParameter forKey:key];
|
||||
}
|
||||
}
|
||||
*interpolatedParameters = parsedParameters;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -125,6 +125,16 @@
|
||||
expect(interpolatedPath).to.equal(expectedPath);
|
||||
}
|
||||
|
||||
- (void)testThatEscapedParametersAreUnescapedWhenCreatingPathFromObject
|
||||
{
|
||||
NSDictionary *arguments = @{ @"name": @"Blake Watters" };
|
||||
RKPathMatcher *matcher = [RKPathMatcher pathMatcherWithPattern:@"/names/:name"];
|
||||
NSDictionary *params = nil;
|
||||
[matcher pathFromObject:arguments addingEscapes:YES interpolatedParameters:¶ms];
|
||||
expect(params).notTo.beNil();
|
||||
expect([params objectForKey:@"name"]).to.equal(@"Blake Watters");
|
||||
}
|
||||
|
||||
- (void)testMatchingPathWithTrailingSlashAndQuery
|
||||
{
|
||||
RKPathMatcher *pathMatcher = [RKPathMatcher pathMatcherWithPattern:@"/api/v1/organizations/"];
|
||||
|
||||
Reference in New Issue
Block a user