fix: path comparison considers core params

This commit is contained in:
Carlos Valente
2026-02-21 21:06:04 +01:00
committed by Carlos Valente
parent df588b8845
commit d9a18b0c42
2 changed files with 17 additions and 6 deletions
+9 -6
View File
@@ -151,16 +151,19 @@ export function arePathsEquivalent(currentPath: string, newPath: string): boolea
const currentUrl = new URL(currentPath, document.location.origin);
const newUrl = new URL(newPath, document.location.origin);
// For preset paths, only compare the path
if (currentUrl.pathname.startsWith('/preset/') || newUrl.pathname.startsWith('/preset/')) {
return currentUrl.pathname === newUrl.pathname;
}
// For regular paths, compare path and search params (ignoring token)
if (currentUrl.pathname !== newUrl.pathname) {
return false;
}
// For preset paths, only n and token are meaningful — ignore everything else
if (currentUrl.pathname.startsWith('/preset/')) {
return (
currentUrl.searchParams.get('n') === newUrl.searchParams.get('n') &&
currentUrl.searchParams.get('token') === newUrl.searchParams.get('token')
);
}
// For regular paths, compare all search params except n and token
currentUrl.searchParams.delete('token');
currentUrl.searchParams.delete('n');
newUrl.searchParams.delete('token');