Permalink
Browse files

Fix asset resolver url handling

Summary:
1. file:// may get prepended to an http:// source URL during dev mode, making an invalid URL
2. the logic to detect `isLoadedFromFileSystem()` should've checked for file:// protocol to not get confused by http:// URL

Reviewed By: zahanm

Differential Revision: D6307187

fbshipit-source-id: e7e7a41bf721dd0601b0c1877e278e1e435ef5e2
  • Loading branch information...
fkgozali authored and facebook-github-bot committed Nov 13, 2017
1 parent 266ab7a commit 28d5d6baf1e6ac52e8672a653f56c3898e4e11d2
Showing with 2 additions and 2 deletions.
  1. +1 −1 Libraries/Image/AssetSourceResolver.js
  2. +1 −1 Libraries/Image/resolveAssetSource.js
@@ -73,7 +73,7 @@ class AssetSourceResolver {
}
isLoadedFromFileSystem(): boolean {
return !!this.jsbundleUrl;
return !!(this.jsbundleUrl && this.jsbundleUrl.startsWith('file://'));
}
canLoadFromEmbeddedBundledLocation(): boolean {
@@ -43,7 +43,7 @@ function _coerceLocalScriptURL(scriptURL: ?string): ?string {
return null;
}
scriptURL = scriptURL.substring(0, scriptURL.lastIndexOf('/') + 1);
if (!scriptURL.startsWith('file://')) {
if (!scriptURL.includes('://')) {
// Add file protocol in case we have an absolute file path and not a URL.
// This shouldn't really be necessary. scriptURL should be a URL.
scriptURL = 'file://' + scriptURL;

0 comments on commit 28d5d6b

Please sign in to comment.