From 44a025babf1de88e5dfebba96830792644a36448 Mon Sep 17 00:00:00 2001 From: "Antoine Vandevenne (anv)" Date: Wed, 15 Jun 2022 09:20:45 +0200 Subject: [PATCH] [FIX] odoo_theme: stop testing for valid URLs if in localhost The mechanism that makes the version and language switchers test for valid URLs crashed when testing in localhost. The mechanism is now skipped if the URL starts with a '/'. X-original-commit: 98e98f65c96acf6f102b9d462ad4f5c0868bd048 --- extensions/odoo_theme/static/js/switchers.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/extensions/odoo_theme/static/js/switchers.js b/extensions/odoo_theme/static/js/switchers.js index e34bbe8d8..8cbb82646 100644 --- a/extensions/odoo_theme/static/js/switchers.js +++ b/extensions/odoo_theme/static/js/switchers.js @@ -15,10 +15,13 @@ document.querySelectorAll('a[class="dropdown-item"]').forEach(element => { element.addEventListener('click', async event => { if (element.hasAttribute('href')) { - event.preventDefault(); - const fallbackUrls = await _generateFallbackUrls(element.getAttribute('href')); - const fallbackUrl = await _getFirstValidUrl(fallbackUrls); - window.location.href = fallbackUrl; + const targetUrl = element.getAttribute('href'); + if (!targetUrl.startWith('/')) { // Don't test for valid URLs if in localhost. + event.preventDefault(); + const fallbackUrls = await _generateFallbackUrls(targetUrl); + const fallbackUrl = await _getFirstValidUrl(fallbackUrls); + window.location.href = fallbackUrl; + } } }); });