[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 3780b0e135
commit 9f69d7d402

View File

@ -15,11 +15,14 @@
document.querySelectorAll('a[class="dropdown-item"]').forEach(element => {
element.addEventListener('click', async event => {
if (element.hasAttribute('href')) {
const targetUrl = element.getAttribute('href');
if (!targetUrl.startWith('/')) { // Don't test for valid URLs if in localhost.
event.preventDefault();
const fallbackUrls = await _generateFallbackUrls(element.getAttribute('href'));
const fallbackUrls = await _generateFallbackUrls(targetUrl);
const fallbackUrl = await _getFirstValidUrl(fallbackUrls);
window.location.href = fallbackUrl;
}
}
});
});
};