From b478dcbb757b45e3c23176fa9f4c0a34e993eaa8 Mon Sep 17 00:00:00 2001 From: fkakatie Date: Thu, 5 Feb 2026 15:08:29 -0800 Subject: [PATCH 1/3] refactor: use import.meta.url for codeBasePath detection --- src/setup.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/setup.js b/src/setup.js index 04177a3..28b2572 100644 --- a/src/setup.js +++ b/src/setup.js @@ -22,15 +22,11 @@ export function setup() { window.hlx.codeBasePath = ''; window.hlx.lighthouse = new URLSearchParams(window.location.search).get('lighthouse') === 'on'; - const scriptEl = document.querySelector('script[src$="/scripts/scripts.js"]'); - if (scriptEl) { - try { - [window.hlx.codeBasePath] = new URL(scriptEl.src).pathname.split('/scripts/scripts.js'); - /* c8 ignore next 4 */ - } catch (error) { - // eslint-disable-next-line no-console - console.log(error); - } + try { + [window.hlx.codeBasePath] = new URL(import.meta.url).pathname.split('/scripts/'); + } catch (error) { + // eslint-disable-next-line no-console + console.log(error); } } From b805dc97f979f1ec39f98bd089328c1154c0309a Mon Sep 17 00:00:00 2001 From: fkakatie Date: Thu, 5 Feb 2026 15:08:45 -0800 Subject: [PATCH 2/3] test: update setup test for import.meta.url approach --- test/setup/setup.test.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/test/setup/setup.test.html b/test/setup/setup.test.html index 586a720..b3368d5 100644 --- a/test/setup/setup.test.html +++ b/test/setup/setup.test.html @@ -1,8 +1,5 @@ - - -