mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
Fixed iOS 7 support for URL query functions
Summary: public Unfortunately, it turns out that NSURLComponents.queryItems only works on iOS 8 and above. This diff re-implements the RCTGetURLQueryParam and RCTURLByReplacingQueryParam functions using functionality available in iOS 7. Reviewed By: javache Differential Revision: D2803679 fb-gh-sync-id: 56f10bef4894d16197975b6023b7aa5ab106d8cb
This commit is contained in:
committed by
facebook-github-bot-4
parent
2462c8f87d
commit
180fc06b7a
@@ -30,6 +30,13 @@
|
||||
XCTAssertEqualObjects(bar, @"foo");
|
||||
}
|
||||
|
||||
- (void)testGetEncodedParam
|
||||
{
|
||||
NSURL *URL = [NSURL URLWithString:@"http://example.com?foo=You%20%26%20Me"];
|
||||
NSString *foo = RCTGetURLQueryParam(URL, @"foo");
|
||||
XCTAssertEqualObjects(foo, @"You & Me");
|
||||
}
|
||||
|
||||
- (void)testQueryParamNotFound
|
||||
{
|
||||
NSURL *URL = [NSURL URLWithString:@"http://example.com?foo=bar"];
|
||||
@@ -58,6 +65,13 @@
|
||||
XCTAssertEqualObjects(result.absoluteString, @"http://example.com?foo=foo&bar=foo");
|
||||
}
|
||||
|
||||
- (void)testReplaceEncodedParam
|
||||
{
|
||||
NSURL *URL = [NSURL URLWithString:@"http://example.com?foo=You%20%26%20Me"];
|
||||
NSURL *result = RCTURLByReplacingQueryParam(URL, @"foo", @"Me & You");
|
||||
XCTAssertEqualObjects(result.absoluteString, @"http://example.com?foo=Me%20%26%20You");
|
||||
}
|
||||
|
||||
- (void)testAppendParam
|
||||
{
|
||||
NSURL *URL = [NSURL URLWithString:@"http://example.com?bar=foo"];
|
||||
|
||||
Reference in New Issue
Block a user