Fix: Error after logging out and selecting another language (#924)

Fix exception url after logout
This commit is contained in:
Ludy 2024-03-17 10:57:17 +01:00 committed by GitHub
parent f474651f36
commit 51bb26ae34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -47,8 +47,10 @@ function handleDropdownItemClick(event) {
localStorage.setItem("languageCode", languageCode);
const currentUrl = window.location.href;
if (currentUrl.indexOf("?lang=") === -1) {
if (currentUrl.indexOf("?lang=") === -1 && currentUrl.indexOf("&lang=") === -1) {
window.location.href = currentUrl + "?lang=" + languageCode;
} else if (currentUrl.indexOf("&lang=") !== -1 && currentUrl.indexOf("?lang=") === -1) {
window.location.href = currentUrl.replace(/&lang=\w{2,}/, "&lang=" + languageCode);
} else {
window.location.href = currentUrl.replace(/\?lang=\w{2,}/, "?lang=" + languageCode);
}

View file

@ -118,10 +118,12 @@
console.log("currentLang", currentLang)
console.log("languageCode", languageCode)
const currentUrl = window.location.href;
if (currentUrl.indexOf('?lang=') === -1) {
window.location.href = currentUrl + '?lang=' + languageCode;
if (currentUrl.indexOf("?lang=") === -1 && currentUrl.indexOf("&lang=") === -1) {
window.location.href = currentUrl + "?lang=" + languageCode;
} else if (currentUrl.indexOf("&lang=") !== -1 && currentUrl.indexOf("?lang=") === -1) {
window.location.href = currentUrl.replace(/&lang=\w{2,}/, "&lang=" + languageCode);
} else {
window.location.href = currentUrl.replace(/\?lang=\w{2,}/, '?lang=' + languageCode);
window.location.href = currentUrl.replace(/\?lang=\w{2,}/, "?lang=" + languageCode);
}
}
dropdown.innerHTML = event.currentTarget.innerHTML; // Update the dropdown button's content