Check whether packager is running in RCTBundleURLProvider for saved JSLocation
Summary: Changelog: Adding packager running check when RCTBundleURLProvider is returning JSLocation, this prevents an invalid address from being returned which might cause various issues. Reviewed By: cpojer Differential Revision: D22390156 fbshipit-source-id: a20dbf63103158a34cbf6dc0ae8349b2f9e5b0a8
This commit is contained in:
Родитель
8a14b98193
Коммит
3d882495d5
|
@ -10,6 +10,8 @@
|
|||
#import <React/RCTBundleURLProvider.h>
|
||||
#import <React/RCTUtils.h>
|
||||
|
||||
#import "OCMock/OCMock.h"
|
||||
|
||||
static NSString *const testFile = @"test.jsbundle";
|
||||
static NSString *const mainBundle = @"main.jsbundle";
|
||||
|
||||
|
@ -94,6 +96,8 @@ static NSURL *ipBundleURL()
|
|||
|
||||
- (void)testIPURL
|
||||
{
|
||||
id classMock = OCMClassMock([RCTBundleURLProvider class]);
|
||||
[[[classMock stub] andReturnValue:@YES] isPackagerRunning:[OCMArg any]];
|
||||
RCTBundleURLProvider *settings = [RCTBundleURLProvider sharedSettings];
|
||||
settings.jsLocation = @"192.168.1.1";
|
||||
NSURL *URL = [settings jsBundleURLForBundleRoot:testFile fallbackResource:nil];
|
||||
|
|
|
@ -125,6 +125,11 @@ static NSURL *serverRootWithHostPort(NSString *hostPort)
|
|||
- (NSString *)packagerServerHost
|
||||
{
|
||||
NSString *location = [self jsLocation];
|
||||
#if RCT_DEV_MENU
|
||||
if (![RCTBundleURLProvider isPackagerRunning:location]) {
|
||||
location = nil;
|
||||
}
|
||||
#endif
|
||||
if (location != nil) {
|
||||
return location;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче