Created
December 3, 2024 09:54
-
-
Save cahva/8f70777ceff47515b909e01168d28e43 to your computer and use it in GitHub Desktop.
Set language parameter if it does not exist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Only proceed if we're not on a register page | |
if (!window.location.pathname.includes('/register')) { | |
const params = new URLSearchParams(window.location.search); | |
// Only add language param if it doesn't exist | |
if (!params.has('language')) { | |
params.append('language', 'en'); | |
// Construct new URL with updated params | |
const newUrl = window.location.pathname + '?' + params.toString() + window.location.hash; | |
window.history.replaceState(null, '', newUrl); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment