From 12543d557f00545a719b4dfd76cc0d0adfa37a01 Mon Sep 17 00:00:00 2001 From: Jimmy Zhang Date: Thu, 20 Aug 2020 09:22:10 -0700 Subject: [PATCH] Remove port from JSLocation when returning packager host Summary: Changelog: Some callsites may rely on the assumption that address return by this method does not contain port information. JSLocation saved in NSUserDefault might contain port information, removing it here can prevent the issue for callsites. Differential Revision: D23240495 fbshipit-source-id: a2edf4abb086fd951dd089331407bd659aad1729 --- React/Base/RCTBundleURLProvider.mm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/React/Base/RCTBundleURLProvider.mm b/React/Base/RCTBundleURLProvider.mm index 6781f034ebb087..146280bf717507 100644 --- a/React/Base/RCTBundleURLProvider.mm +++ b/React/Base/RCTBundleURLProvider.mm @@ -125,6 +125,12 @@ + (BOOL)isPackagerRunning:(NSString *)host - (NSString *)packagerServerHost { NSString *location = [self jsLocation]; + if (location) { + NSInteger index = [location rangeOfString:@":"].location; + if (index != NSNotFound) { + location = [location substringToIndex:index]; + } + } #if RCT_DEV_MENU if ([location length] && ![RCTBundleURLProvider isPackagerRunning:location]) { location = nil;