mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Refactor redirectToHome function to use URL object
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user