Skip to content

Commit 32c9609

Browse files
committed
fix: handle case where web URL is http://origin:port/
The previous code for extracting the tracker's TRACKER_WEB setting didn't account for a missing tracker name component (i.e. tracker is the root of the site). Use something a little more robust that generates the base path by removing last '/' delimited component from the path of the current document's URL. This doesn't work if the user deploys the classhelper on the home page. The page URL must have exactly one component to strip to get the base URL.
1 parent 0e4a99f commit 32c9609

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

share/roundup/templates/classic/html/classhelper.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ class ClassHelper extends HTMLElement {
314314
ClassHelper.translations[key] = key;
315315
}
316316

317-
let tracker = window.location.pathname.split('/')[1];
318-
let url = new URL(window.location.origin + "/" + tracker + '/');
317+
let tracker_path = window.location.pathname.split('/').slice(0,-1).join('/')
318+
let url = new URL(window.location.origin + tracker_path + '/');
319319
url.searchParams.append("@template", "translation");
320320
url.searchParams.append("properties", Array.from(keys.values()).join(','));
321321

0 commit comments

Comments
 (0)