@@ -76,9 +76,9 @@ - (void)resetToDefaults
76
76
}
77
77
78
78
#if RCT_DEV_MENU
79
- + (BOOL )isPackagerRunning : (NSString *)host
79
+ + (BOOL )isPackagerRunning : (NSString *)hostPort
80
80
{
81
- NSURL *url = [serverRootWithHostPort (host ) URLByAppendingPathComponent: @" status" ];
81
+ NSURL *url = [serverRootWithHostPort (hostPort ) URLByAppendingPathComponent: @" status" ];
82
82
83
83
NSURLSession *session = [NSURLSession sharedSession ];
84
84
NSURLRequest *request = [NSURLRequest requestWithURL: url];
@@ -116,21 +116,27 @@ - (NSString *)guessPackagerHost
116
116
return nil ;
117
117
}
118
118
#else
119
- + (BOOL )isPackagerRunning : (NSString *)host
119
+ + (BOOL )isPackagerRunning : (NSString *)hostPort
120
120
{
121
121
return false ;
122
122
}
123
123
#endif
124
124
125
125
- (NSString *)packagerServerHost
126
126
{
127
- NSString *location = [self jsLocation ];
127
+ NSString *location = [self packagerServerHostPort ];
128
128
if (location) {
129
129
NSInteger index = [location rangeOfString: @" :" ].location ;
130
130
if (index != NSNotFound ) {
131
131
location = [location substringToIndex: index ];
132
132
}
133
133
}
134
+ return location;
135
+ }
136
+
137
+ - (NSString *)packagerServerHostPort
138
+ {
139
+ NSString *location = [self jsLocation ];
134
140
#if RCT_DEV_MENU
135
141
if ([location length ] && ![RCTBundleURLProvider isPackagerRunning: location]) {
136
142
location = nil ;
@@ -150,12 +156,12 @@ - (NSString *)packagerServerHost
150
156
151
157
- (NSURL *)jsBundleURLForBundleRoot : (NSString *)bundleRoot fallbackURLProvider : (NSURL * (^)(void ))fallbackURLProvider
152
158
{
153
- NSString *packagerServerHost = [self packagerServerHost ];
154
- if (!packagerServerHost ) {
159
+ NSString *packagerServerHostPort = [self packagerServerHostPort ];
160
+ if (!packagerServerHostPort ) {
155
161
return fallbackURLProvider ();
156
162
} else {
157
163
return [RCTBundleURLProvider jsBundleURLForBundleRoot: bundleRoot
158
- packagerHost: packagerServerHost
164
+ packagerHost: packagerServerHostPort
159
165
enableDev: [self enableDev ]
160
166
enableMinification: [self enableMinification ]];
161
167
}
@@ -164,7 +170,7 @@ - (NSURL *)jsBundleURLForBundleRoot:(NSString *)bundleRoot fallbackURLProvider:(
164
170
- (NSURL *)jsBundleURLForSplitBundleRoot : (NSString *)bundleRoot
165
171
{
166
172
return [RCTBundleURLProvider jsBundleURLForBundleRoot: bundleRoot
167
- packagerHost: [self packagerServerHost ]
173
+ packagerHost: [self packagerServerHostPort ]
168
174
enableDev: [self enableDev ]
169
175
enableMinification: [self enableMinification ]
170
176
modulesOnly: YES
@@ -198,14 +204,14 @@ - (NSURL *)resourceURLForResourceRoot:(NSString *)root
198
204
resourceExtension : (NSString *)extension
199
205
offlineBundle : (NSBundle *)offlineBundle
200
206
{
201
- NSString *packagerServerHost = [self packagerServerHost ];
202
- if (!packagerServerHost ) {
207
+ NSString *packagerServerHostPort = [self packagerServerHostPort ];
208
+ if (!packagerServerHostPort ) {
203
209
// Serve offline bundle (local file)
204
210
NSBundle *bundle = offlineBundle ?: [NSBundle mainBundle ];
205
211
return [bundle URLForResource: name withExtension: extension];
206
212
}
207
213
NSString *path = [NSString stringWithFormat: @" /%@ /%@ .%@ " , root, name, extension];
208
- return [[self class ] resourceURLForResourcePath: path packagerHost: packagerServerHost query: nil ];
214
+ return [[self class ] resourceURLForResourcePath: path packagerHost: packagerServerHostPort query: nil ];
209
215
}
210
216
211
217
+ (NSURL *)jsBundleURLForBundleRoot : (NSString *)bundleRoot
0 commit comments