Skip to content

Commit

Permalink
Fix asset resolver url handling
Browse files Browse the repository at this point in the history
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 28d5d6b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Libraries/Image/AssetSourceResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class AssetSourceResolver {
}

isLoadedFromFileSystem(): boolean {
return !!this.jsbundleUrl;
return !!(this.jsbundleUrl && this.jsbundleUrl.startsWith('file://'));
}

canLoadFromEmbeddedBundledLocation(): boolean {
Expand Down
2 changes: 1 addition & 1 deletion Libraries/Image/resolveAssetSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 28d5d6b

Please sign in to comment.