Skip to content

Commit 0083294

Browse files
committed
chore: Eliminate repeated code about shallow routing in LocationLite
1 parent 0a23f30 commit 0083294

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/lib/core/LocationLite.svelte.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ export class LocationLite implements Location {
7777
}
7878

7979
#goTo(url: string, replace: boolean, state: State | undefined) {
80+
if (url === '') {
81+
// Shallow routing.
82+
url = this.url.href;
83+
}
8084
(
8185
replace ?
8286
globalThis.window?.history.replaceState :
@@ -87,10 +91,6 @@ export class LocationLite implements Location {
8791
}
8892

8993
goTo(url: string, options?: GoToOptions): void {
90-
if (url === '') {
91-
// Shallow routing.
92-
url = this.url.href;
93-
}
9494
if (options?.preserveQuery) {
9595
url = preserveQueryInUrl(url, options.preserveQuery);
9696
}
@@ -99,11 +99,7 @@ export class LocationLite implements Location {
9999

100100
navigate(url: string, options?: NavigateOptions): void {
101101
const resolvedHash = resolveHashValue(options?.hash);
102-
if (url === '') {
103-
// Shallow routing.
104-
url = this.url.href;
105-
}
106-
else {
102+
if (url !== '') {
107103
url = calculateHref({
108104
...options,
109105
hash: resolvedHash,

0 commit comments

Comments
 (0)