Improved null url handling

Summary:
public
Attempting to load an undefined URL via XMLHttpRequest produced a confusing error deep within the network layer. This diff improves the networking stack to catch such errors earlier, and also adds a helpful error in the JS layer.

Fixes https://github.com/facebook/react-native/issues/4558

Reviewed By: javache

Differential Revision: D2811080

fb-gh-sync-id: 1837427e1080a0308f2c4f9a8a42bce2e041fb48
This commit is contained in:
Nick Lockwood
2016-01-07 04:00:15 -08:00
committed by facebook-github-bot-8
parent 57f6cbb3dc
commit 571e646543
3 changed files with 12 additions and 1 deletions

View File

@@ -494,7 +494,11 @@ NSString *RCTBundlePathForURL(NSURL *URL)
// Not a bundle-relative file
return nil;
}
return [path substringFromIndex:bundlePath.length + 1];
path = [path substringFromIndex:bundlePath.length];
if ([path hasPrefix:@"/"]) {
path = [path substringFromIndex:1];
}
return path;
}
BOOL RCTIsXCAssetURL(NSURL *imageURL)