diff --git a/PINCache/PINDiskCache.m b/PINCache/PINDiskCache.m index ca93bacf..0ded6757 100644 --- a/PINCache/PINDiskCache.m +++ b/PINCache/PINDiskCache.m @@ -143,7 +143,7 @@ - (NSString *)encodedString:(NSString *)string { if (![string length]) return @""; - return [string stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@".:/"]]; + return [string stringByAddingPercentEncodingWithAllowedCharacters:[[NSCharacterSet characterSetWithCharactersInString:@".:/"] invertedSet]]; } - (NSString *)decodedString:(NSString *)string diff --git a/tests/PINCacheTests/PINCacheTests.m b/tests/PINCacheTests/PINCacheTests.m index e9672bbf..c9ff7665 100644 --- a/tests/PINCacheTests/PINCacheTests.m +++ b/tests/PINCacheTests/PINCacheTests.m @@ -8,6 +8,12 @@ NSString * const PINCacheTestName = @"PINCacheTest"; NSTimeInterval PINCacheTestBlockTimeout = 5.0; +@interface PINDiskCache() + +- (NSString *)encodedString:(NSString *)string; + +@end + @interface PINCacheTests () @property (strong, nonatomic) PINCache *cache; @end @@ -62,6 +68,12 @@ - (dispatch_time_t)timeout #pragma mark - Tests - +- (void)testDiskCacheStringEncoding +{ + NSString *string = [self.cache.diskCache encodedString:@"http://www.test.de-"]; + XCTAssertTrue([string isEqualToString:@"http%3A%2F%2Fwww%2Etest%2Ede-"]); +} + - (void)testCoreProperties { PINCache *cache = [[PINCache alloc] initWithName:PINCacheTestName];