Skip to content

Commit 89d7e18

Browse files
authored
fix: Use full URL when standardizing state (#12)
1 parent 3983865 commit 89d7e18

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/lib/SkHistoryApi.svelte.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ const hoistedVars = vi.hoisted(() => ({
4747

4848
vi.mock(import("$app/state"), async (importOriginal) => {
4949
return {
50-
...importOriginal,
50+
...await importOriginal(),
5151
page: {
5252
get url() {
53-
return hoistedVars.urlMock();
53+
return hoistedVars.urlMock() ?? new URL("http://localhost/");
5454
},
5555
get state() {
5656
return hoistedVars.stateMock();
57-
}
57+
},
5858
} as Page
5959
}
6060
});

src/lib/SkHistoryApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class SkHistoryApi implements HistoryApi {
1515
if (browser && !isConformantState(page.state)) {
1616
// I tried with replaceState() here, throws with error "cannot use before router initializes".
1717
// So, using goto() with replaceState: true. This triggers an update on page.url, though.
18-
goto('', { replaceState: true, state: { path: page.state, hash: {} } });
18+
goto(page.url.toString(), { replaceState: true, state: { path: page.state, hash: {} } });
1919
}
2020
}
2121

0 commit comments

Comments
 (0)