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
This commit is contained in:
Kevin Gozali 2017-11-12 22:48:56 -08:00 коммит произвёл Facebook Github Bot
Родитель 266ab7a006
Коммит 28d5d6baf1
2 изменённых файлов: 2 добавлений и 2 удалений

Просмотреть файл

@ -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;