Replace deprecated `stringByReplacingPercentEscapesUsingEncoding:` with `stringByAddingPercentEncodingWithAllowedCharacters:` (#19792)
Summary: Replace some NSString deprecated methods. motivation for these prs is less warnings reported on xcode everytime we compile a rn app. N/A [INTERNAL] [DEPRECATIONS] [NSString] - Replace NSString deprecation methods. Pull Request resolved: https://github.com/facebook/react-native/pull/19792 Differential Revision: D8515136 Pulled By: cpojer fbshipit-source-id: 4379ef4e229ef201685b87e54ac859ba3d30a833
This commit is contained in:
parent
5be50d4820
commit
61ca119650
|
@ -89,7 +89,14 @@ RCT_CUSTOM_CONVERTER(NSData *, NSData, [json dataUsingEncoding:NSUTF8StringEncod
|
|||
|
||||
// Check if it has a scheme
|
||||
if ([path rangeOfString:@":"].location != NSNotFound) {
|
||||
path = [path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
NSMutableCharacterSet *urlAllowedCharacterSet = [NSMutableCharacterSet new];
|
||||
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLUserAllowedCharacterSet]];
|
||||
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLPasswordAllowedCharacterSet]];
|
||||
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLHostAllowedCharacterSet]];
|
||||
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLPathAllowedCharacterSet]];
|
||||
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLQueryAllowedCharacterSet]];
|
||||
[urlAllowedCharacterSet formUnionWithCharacterSet:[NSCharacterSet URLFragmentAllowedCharacterSet]];
|
||||
path = [path stringByAddingPercentEncodingWithAllowedCharacters:urlAllowedCharacterSet];
|
||||
URL = [NSURL URLWithString:path];
|
||||
if (URL) {
|
||||
return URL;
|
||||
|
|
|
@ -33,8 +33,8 @@ static NSString *getServerHost(NSURL *bundleURL, NSNumber *port)
|
|||
static NSURL *getInspectorDeviceUrl(NSURL *bundleURL)
|
||||
{
|
||||
NSNumber *inspectorProxyPort = @8082;
|
||||
NSString *escapedDeviceName = [[[UIDevice currentDevice] name] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
NSString *escapedDeviceName = [[[UIDevice currentDevice] name] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
|
||||
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
|
||||
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/inspector/device?name=%@&app=%@",
|
||||
getServerHost(bundleURL, inspectorProxyPort),
|
||||
escapedDeviceName,
|
||||
|
@ -44,8 +44,8 @@ static NSURL *getInspectorDeviceUrl(NSURL *bundleURL)
|
|||
static NSURL *getAttachDeviceUrl(NSURL *bundleURL, NSString *title)
|
||||
{
|
||||
NSNumber *metroBundlerPort = @8081;
|
||||
NSString *escapedDeviceName = [[[UIDevice currentDevice] name] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
NSString *escapedDeviceName = [[[UIDevice currentDevice] name] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
|
||||
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
|
||||
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/attach-debugger-nuclide?title=%@&device=%@&app=%@",
|
||||
getServerHost(bundleURL, metroBundlerPort),
|
||||
title,
|
||||
|
|
|
@ -247,7 +247,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
|
|||
if (isJSNavigation && [request.URL.host isEqualToString:kPostMessageHost]) {
|
||||
NSString *data = request.URL.query;
|
||||
data = [data stringByReplacingOccurrencesOfString:@"+" withString:@" "];
|
||||
data = [data stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||
data = [data stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLQueryAllowedCharacterSet];
|
||||
|
||||
NSMutableDictionary<NSString *, id> *event = [self baseEvent];
|
||||
[event addEntriesFromDictionary: @{
|
||||
|
|
Loading…
Reference in New Issue