From 00832947db063ed96f3391c5099c0398a17bcc76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramirez=20Vargas=2C=20Jos=C3=A9=20Pablo?= Date: Thu, 4 Sep 2025 20:27:33 -0600 Subject: [PATCH] chore: Eliminate repeated code about shallow routing in LocationLite --- src/lib/core/LocationLite.svelte.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/lib/core/LocationLite.svelte.ts b/src/lib/core/LocationLite.svelte.ts index e1728d4..62914d4 100644 --- a/src/lib/core/LocationLite.svelte.ts +++ b/src/lib/core/LocationLite.svelte.ts @@ -77,6 +77,10 @@ export class LocationLite implements Location { } #goTo(url: string, replace: boolean, state: State | undefined) { + if (url === '') { + // Shallow routing. + url = this.url.href; + } ( replace ? globalThis.window?.history.replaceState : @@ -87,10 +91,6 @@ export class LocationLite implements Location { } goTo(url: string, options?: GoToOptions): void { - if (url === '') { - // Shallow routing. - url = this.url.href; - } if (options?.preserveQuery) { url = preserveQueryInUrl(url, options.preserveQuery); } @@ -99,11 +99,7 @@ export class LocationLite implements Location { navigate(url: string, options?: NavigateOptions): void { const resolvedHash = resolveHashValue(options?.hash); - if (url === '') { - // Shallow routing. - url = this.url.href; - } - else { + if (url !== '') { url = calculateHref({ ...options, hash: resolvedHash,