From 32c960931f31555f136011e4024dbc26e17b5039 Mon Sep 17 00:00:00 2001 From: John Rouillard Date: Mon, 27 May 2024 22:37:35 -0400 Subject: [PATCH] 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. --- share/roundup/templates/classic/html/classhelper.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/share/roundup/templates/classic/html/classhelper.js b/share/roundup/templates/classic/html/classhelper.js index fb59192c..252734f1 100644 --- a/share/roundup/templates/classic/html/classhelper.js +++ b/share/roundup/templates/classic/html/classhelper.js @@ -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(','));