Fix: Error after logging out and selecting another language (#924)
Fix exception url after logout
This commit is contained in:
parent
f474651f36
commit
51bb26ae34
2 changed files with 8 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue