Skip to content

Commit 28d5d6b

Browse files
fkgozalifacebook-github-bot
authored andcommitted
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
1 parent 266ab7a commit 28d5d6b

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

Libraries/Image/AssetSourceResolver.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class AssetSourceResolver {
7373
}
7474

7575
isLoadedFromFileSystem(): boolean {
76-
return !!this.jsbundleUrl;
76+
return !!(this.jsbundleUrl && this.jsbundleUrl.startsWith('file://'));
7777
}
7878

7979
canLoadFromEmbeddedBundledLocation(): boolean {

Libraries/Image/resolveAssetSource.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function _coerceLocalScriptURL(scriptURL: ?string): ?string {
4343
return null;
4444
}
4545
scriptURL = scriptURL.substring(0, scriptURL.lastIndexOf('/') + 1);
46-
if (!scriptURL.startsWith('file://')) {
46+
if (!scriptURL.includes('://')) {
4747
// Add file protocol in case we have an absolute file path and not a URL.
4848
// This shouldn't really be necessary. scriptURL should be a URL.
4949
scriptURL = 'file://' + scriptURL;

0 commit comments

Comments
 (0)