[FIX] http_routing: remove trailing /
Currently, the character `/` appears at the end of the url of the
language dropdown on the home page e.g. /en/, /fr/. This will cause one
more redirect when performing the language change.
Indeed, this error is only encountered with path = /
Please try the following `url_lang('/', 'en_US')` => /en/
After this fix, the trailing `/` will be removed when using the func
`url_lang` e.g. `url_lang('', 'en_US')` => /en, this means that the
language switching links on the homepage no longer redirect redundantly
again.
closes odoo/odoo#106109
Signed-off-by: Romain Derie (rde) <rde@odoo.com>
This commit is contained in:
@@ -167,6 +167,9 @@ def url_lang(path_or_uri, lang_code=None):
|
||||
# Insert the context language or the provided language
|
||||
elif lang_url_code != default_lg.url_code or force_lang:
|
||||
ps.insert(1, lang_url_code)
|
||||
# Remove the last empty string to avoid trailing / after joining
|
||||
if ps[-1] == '':
|
||||
ps.pop(-1)
|
||||
|
||||
location = u'/'.join(ps) + sep + qs
|
||||
return location
|
||||
|
||||
@@ -77,7 +77,7 @@ class TestQwebProcessAtt(TransactionCase):
|
||||
|
||||
def test_process_att_with_request_lang(self):
|
||||
with MockRequest(self.env, website=self.website, context={'lang': 'fr_FR'}):
|
||||
self._test_att('/', {'href': '/fr/'})
|
||||
self._test_att('/', {'href': '/fr'})
|
||||
self._test_att('/en/', {'href': '/'})
|
||||
self._test_att('/fr/', {'href': '/fr/'})
|
||||
self._test_att('/fr', {'href': '/fr'})
|
||||
|
||||
Reference in New Issue
Block a user