diff --git a/public/scripts/login.js b/public/scripts/login.js index bb5f67fbe..6ef26abf7 100644 --- a/public/scripts/login.js +++ b/public/scripts/login.js @@ -180,13 +180,18 @@ function displayError(message) { * Preserves the query string. */ function redirectToHome() { - // After a login theres no need to preserve the - // noauto (if present) - const urlParams = new URLSearchParams(window.location.search); + // Create a URL object based on the current location + const currentUrl = new URL(window.location.href); - urlParams.delete('noauto'); + // After a login there's no need to preserve the + // noauto parameter (if present) + currentUrl.searchParams.delete('noauto'); - window.location.href = '/' + urlParams.toString(); + // Set the pathname to root and keep the updated query string + currentUrl.pathname = '/'; + + // Redirect to the new URL + window.location.href = currentUrl.toString(); } /**