Skip to content

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

@rouilj

Description

@rouilj

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:

the translation won't work. Also there is one other place that looks at a pathname component
that might be an issue (or might not, I'm not sure what the source URL for the 2nd pathname reference
is.)

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-).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions