From 28d5d6baf1e6ac52e8672a653f56c3898e4e11d2 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Sun, 12 Nov 2017 22:48:56 -0800 Subject: [PATCH] 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 --- Libraries/Image/AssetSourceResolver.js | 2 +- Libraries/Image/resolveAssetSource.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/Image/AssetSourceResolver.js b/Libraries/Image/AssetSourceResolver.js index a240b5af71601e..4b4e4117f35cba 100644 --- a/Libraries/Image/AssetSourceResolver.js +++ b/Libraries/Image/AssetSourceResolver.js @@ -73,7 +73,7 @@ class AssetSourceResolver { } isLoadedFromFileSystem(): boolean { - return !!this.jsbundleUrl; + return !!(this.jsbundleUrl && this.jsbundleUrl.startsWith('file://')); } canLoadFromEmbeddedBundledLocation(): boolean { diff --git a/Libraries/Image/resolveAssetSource.js b/Libraries/Image/resolveAssetSource.js index aba63045e4d18b..bb46279af4df3c 100644 --- a/Libraries/Image/resolveAssetSource.js +++ b/Libraries/Image/resolveAssetSource.js @@ -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;