[FIX] website: edit master wrongly computed

In case you don't have the trailing slash and are on your homepage, the indexOf
will return -1 and you will be redirectected to the pathname.substr(-1)

Now if you don't have trailing slash in your url after position 1, we don't
subtract anything.

domain.com/fr_BE

Before this commit:
   => redirect to domain.com/E
After thi comit
   => redirect to domain.com

task-2345490

closes odoo/odoo#58458

X-original-commit: ada2e2ce68dbc8b1df701691d9d3e958fef4ea31
Signed-off-by: Jérémy Kersten (jke) <jke@openerp.com>
This commit is contained in:
Jeremy Kersten
2020-09-24 16:23:35 +00:00
parent 7a0aecfca9
commit 27c663a48a
@@ -50,7 +50,7 @@ var TranslatePageMenu = websiteNavbarData.WebsiteNavbarActionWidget.extend({
current.href = window.location.toString();
current.search += (current.search ? '&' : '?') + 'enable_editor=1';
// we are in translate mode, the pathname starts with '/<url_code/'
current.pathname = current.pathname.substr(current.pathname.indexOf('/', 1));
current.pathname = current.pathname.substr(Math.max(0, current.pathname.indexOf('/', 1)));
var link = document.createElement('a');
link.href = '/website/lang/default';