[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: 98e98f65c9
This commit is contained in:
Antoine Vandevenne (anv) 2022-06-15 09:20:45 +02:00
parent 8ac6cea21c
commit 4ff1094cdc

View File

@ -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;
}
}
});
});