From c3d6f3d4e2a31f01d2a0580358ec346efc66de26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ramirez=20Vargas=2C=20Jos=C3=A9=20Pablo?= Date: Wed, 1 Oct 2025 22:34:44 -0600 Subject: [PATCH] fix: Use full URL when standardizing state --- src/lib/SkHistoryApi.svelte.test.ts | 6 +++--- src/lib/SkHistoryApi.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/SkHistoryApi.svelte.test.ts b/src/lib/SkHistoryApi.svelte.test.ts index 0447317..ae27106 100644 --- a/src/lib/SkHistoryApi.svelte.test.ts +++ b/src/lib/SkHistoryApi.svelte.test.ts @@ -47,14 +47,14 @@ const hoistedVars = vi.hoisted(() => ({ vi.mock(import("$app/state"), async (importOriginal) => { return { - ...importOriginal, + ...await importOriginal(), page: { get url() { - return hoistedVars.urlMock(); + return hoistedVars.urlMock() ?? new URL("http://localhost/"); }, get state() { return hoistedVars.stateMock(); - } + }, } as Page } }); diff --git a/src/lib/SkHistoryApi.ts b/src/lib/SkHistoryApi.ts index e7c8ec9..e3f46ec 100644 --- a/src/lib/SkHistoryApi.ts +++ b/src/lib/SkHistoryApi.ts @@ -15,7 +15,7 @@ export class SkHistoryApi implements HistoryApi { if (browser && !isConformantState(page.state)) { // I tried with replaceState() here, throws with error "cannot use before router initializes". // So, using goto() with replaceState: true. This triggers an update on page.url, though. - goto('', { replaceState: true, state: { path: page.state, hash: {} } }); + goto(page.url.toString(), { replaceState: true, state: { path: page.state, hash: {} } }); } }