Skip to content

Commit 761f762

Browse files
Pavlos VinieratosPavlos Vinieratos
authored andcommitted
replace deprecated stringByReplacingPercentEscapesUsingEncoding: with stringByAddingPercentEncodingWithAllowedCharacters:
1 parent aaddbee commit 761f762

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

React/Base/RCTConvert.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ + (NSURL *)NSURL:(id)json
8989

9090
// Check if it has a scheme
9191
if ([path rangeOfString:@":"].location != NSNotFound) {
92-
path = [path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
92+
path = [path stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
9393
URL = [NSURL URLWithString:path];
9494
if (URL) {
9595
return URL;

React/DevSupport/RCTInspectorDevServerHelper.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
static NSURL *getInspectorDeviceUrl(NSURL *bundleURL)
3232
{
3333
NSNumber *inspectorProxyPort = @8082;
34-
NSString *escapedDeviceName = [[[UIDevice currentDevice] name] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
35-
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
34+
NSString *escapedDeviceName = [[[UIDevice currentDevice] name] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
35+
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
3636
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/inspector/device?name=%@&app=%@",
3737
getServerHost(bundleURL, inspectorProxyPort),
3838
escapedDeviceName,
@@ -42,8 +42,8 @@
4242
static NSURL *getAttachDeviceUrl(NSURL *bundleURL, NSString *title)
4343
{
4444
NSNumber *metroBundlerPort = @8081;
45-
NSString *escapedDeviceName = [[[UIDevice currentDevice] name] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
46-
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
45+
NSString *escapedDeviceName = [[[UIDevice currentDevice] name] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
46+
NSString *escapedAppName = [[[NSBundle mainBundle] bundleIdentifier] stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
4747
return [NSURL URLWithString:[NSString stringWithFormat:@"http://%@/attach-debugger-nuclide?title=%@&device=%@&app=%@",
4848
getServerHost(bundleURL, metroBundlerPort),
4949
title,

React/Views/RCTWebView.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ - (BOOL)webView:(__unused UIWebView *)webView shouldStartLoadWithRequest:(NSURLR
247247
if (isJSNavigation && [request.URL.host isEqualToString:kPostMessageHost]) {
248248
NSString *data = request.URL.query;
249249
data = [data stringByReplacingOccurrencesOfString:@"+" withString:@" "];
250-
data = [data stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
250+
data = [data stringByAddingPercentEncodingWithAllowedCharacters:NSCharacterSet.URLHostAllowedCharacterSet];
251251

252252
NSMutableDictionary<NSString *, id> *event = [self baseEvent];
253253
[event addEntriesFromDictionary: @{

0 commit comments

Comments
 (0)