[web] Fix paths fetched by flutter.js (#118684)
This commit is contained in:
@@ -20,6 +20,21 @@ _flutter.loader = null;
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const baseUri = ensureTrailingSlash(getBaseURI());
|
||||
|
||||
function getBaseURI() {
|
||||
const base = document.querySelector("base");
|
||||
return (base && base.getAttribute("href")) || "";
|
||||
}
|
||||
|
||||
function ensureTrailingSlash(uri) {
|
||||
if (uri == "") {
|
||||
return uri;
|
||||
}
|
||||
return uri.endsWith("/") ? uri : `${uri}/`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps `promise` in a timeout of the given `duration` in ms.
|
||||
*
|
||||
@@ -120,8 +135,7 @@ _flutter.loader = null;
|
||||
}
|
||||
const {
|
||||
serviceWorkerVersion,
|
||||
serviceWorkerUrl = "flutter_service_worker.js?v=" +
|
||||
serviceWorkerVersion,
|
||||
serviceWorkerUrl = `${baseUri}flutter_service_worker.js?v=${serviceWorkerVersion}`,
|
||||
timeoutMillis = 4000,
|
||||
} = settings;
|
||||
|
||||
@@ -239,7 +253,7 @@ _flutter.loader = null;
|
||||
* Returns undefined when an `onEntrypointLoaded` callback is supplied in `options`.
|
||||
*/
|
||||
async loadEntrypoint(options) {
|
||||
const { entrypointUrl = "main.dart.js", onEntrypointLoaded } =
|
||||
const { entrypointUrl = `${baseUri}main.dart.js`, onEntrypointLoaded } =
|
||||
options || {};
|
||||
|
||||
return this._loadEntrypoint(entrypointUrl, onEntrypointLoaded);
|
||||
|
||||
Reference in New Issue
Block a user