From 5eaa5aad8bdaeee7925dd7026b9434d40d7277ed Mon Sep 17 00:00:00 2001
From: Christoph Reiter <reiter.christoph@gmail.com>
Date: Wed, 18 Dec 2019 14:56:50 +0100
Subject: [PATCH] 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.
---
 packages/common/test/unit.js | 3 +--
 packages/common/utils.js     | 4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/packages/common/test/unit.js b/packages/common/test/unit.js
index c3a27d84..171b402c 100644
--- a/packages/common/test/unit.js
+++ b/packages/common/test/unit.js
@@ -37,8 +37,7 @@ suite('utils', () => {
 
     test('getAssetURL', () => {
         utils.initAssetBaseURL();
-        assert(utils.getAssetURL("foo/bar") === "foo/bar");
-        assert(utils.getAssetURL("foo/bar") === "foo/bar");
+        assert.equal(new URL(utils.getAssetURL("foo/bar")).pathname, "/foo/bar");
     });
 
     test('getThemeCSS', () => {
diff --git a/packages/common/utils.js b/packages/common/utils.js
index 7c133605..5a357954 100644
--- a/packages/common/utils.js
+++ b/packages/common/utils.js
@@ -203,6 +203,10 @@ export const initAssetBaseURL = (id) => {
     if (document.currentScript && 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;
 };
 
 /**
-- 
GitLab