From 9f445a2083a8587584e0fc510d0ae5a7e3807f14 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Thu, 14 Nov 2024 13:19:12 -0500 Subject: [PATCH] always convert data-webawesome urls to root-relative --- src/utilities/base-path.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/utilities/base-path.ts b/src/utilities/base-path.ts index 0274f94be..85c3c0889 100644 --- a/src/utilities/base-path.ts +++ b/src/utilities/base-path.ts @@ -25,9 +25,10 @@ export function getBasePath(subpath = '') { // If we haven't set the base path yet, let's set it now const el = document.querySelector('[data-webawesome]'); - if (el) { - // Use the data-webawesome attribute - setBasePath(el.getAttribute('data-webawesome') || ''); + if (el?.hasAttribute('data-webawesome')) { + // Use data-webawesome + const rootRelativeUrl = new URL(el.getAttribute('data-webawesome') ?? '', window.location.href).pathname; + setBasePath(rootRelativeUrl); } else { // Look for webawesome.js or webawesome.loader.js const scripts = [...document.getElementsByTagName('script')] as HTMLScriptElement[];