Skip to content

Commit

Permalink
fix: handle case where web URL is http://origin:port/
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rouilj committed May 28, 2024
1 parent 0e4a99f commit 32c9609
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions share/roundup/templates/classic/html/classhelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,8 @@ class ClassHelper extends HTMLElement {
ClassHelper.translations[key] = key;
}

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

Expand Down

0 comments on commit 32c9609

Please sign in to comment.