UMB-CS-682-Team-03 / tracker

0 stars 0 forks source link

Translation endpoint not found if base URL is 'http://host:port/' #87

Open rouilj opened 5 months ago

rouilj commented 5 months ago

If I change:

diff -r 8d3cb6931793 share/roundup/templates/classic/html/classhelper.js
--- a/share/roundup/templates/classic/html/classhelper.js   Mon May 27 17:01:52 2024 -0400
+++ b/share/roundup/templates/classic/html/classhelper.js   Mon May 27 22:13:27 2024 -0400
@@ -314,8 +314,8 @@
             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(','));

so I remove the last element of the path and put it back together again it works.

I seem to remember @patel-malav asking about a similar issue and I think I gave him an incorrect solution.

Found this while I was adapting @BharathKanama test code to the full roundup test harness. I fire up my own server as part of the test harness. It lives at http://localhost:9001/ and this exposed the issue.

This patch will do for the current Roundup release.

If the use case for the classhelper is extended to work on the home page it will break. For example if the classhelper is used at the URL:

or the URL:

We may need a "data-base-url" attribute for this case. It can be assigned by TAL or other templating language to the tracker web address.

Of course I discovered this after I released 2.4.0beta1 8-).

rouilj commented 5 months ago

Committed on 7a75e23