Skip to content
Snippets Groups Projects
Commit 5eaa5aad authored by Reiter, Christoph's avatar Reiter, Christoph :snake:
Browse files

initAssetBaseURL: fall back to import.meta.url

While this will never work with old Edge it makes things easier during testing
where we can't set an id on the script tag. And we still don't know if supporting
old Edge is even needed.
parent b108332c
No related branches found
No related tags found
No related merge requests found
...@@ -37,8 +37,7 @@ suite('utils', () => { ...@@ -37,8 +37,7 @@ suite('utils', () => {
test('getAssetURL', () => { test('getAssetURL', () => {
utils.initAssetBaseURL(); utils.initAssetBaseURL();
assert(utils.getAssetURL("foo/bar") === "foo/bar"); assert.equal(new URL(utils.getAssetURL("foo/bar")).pathname, "/foo/bar");
assert(utils.getAssetURL("foo/bar") === "foo/bar");
}); });
test('getThemeCSS', () => { test('getThemeCSS', () => {
......
...@@ -203,6 +203,10 @@ export const initAssetBaseURL = (id) => { ...@@ -203,6 +203,10 @@ export const initAssetBaseURL = (id) => {
if (document.currentScript && document.currentScript.src) { if (document.currentScript && document.currentScript.src) {
_assetBaseURL = document.currentScript.src; _assetBaseURL = document.currentScript.src;
} }
// XXX: Can't be parsed in (old) edge, but makes everything so much easier...
if (!_assetBaseURL)
_assetBaseURL = new URL('..', import.meta.url).href;
}; };
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment