1
0
mirror of https://github.com/Stirling-Tools/Stirling-PDF.git synced 2024-11-16 12:20:12 +01:00

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); localStorage.setItem("languageCode", languageCode);
const currentUrl = window.location.href; 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; 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 { } else {
window.location.href = currentUrl.replace(/\?lang=\w{2,}/, "?lang=" + languageCode); window.location.href = currentUrl.replace(/\?lang=\w{2,}/, "?lang=" + languageCode);
} }

View File

@ -118,10 +118,12 @@
console.log("currentLang", currentLang) console.log("currentLang", currentLang)
console.log("languageCode", languageCode) console.log("languageCode", languageCode)
const currentUrl = window.location.href; 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; 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 { } 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 dropdown.innerHTML = event.currentTarget.innerHTML; // Update the dropdown button's content