-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(5457): normalize path on prefetch (#5458)
* fix(5457): normalize path on prefetch * Create new-geckos-vanish.md * add test * oops * hmm Co-authored-by: Rich Harris <hello@rich-harris.dev>
- Loading branch information
1 parent
59d03e2
commit d22fbcb
Showing
10 changed files
with
131 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@sveltejs/kit": patch | ||
--- | ||
|
||
Normalize paths on prefetch (fixes #5457) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
packages/kit/test/apps/basics/src/routes/routing/prefetching/hash-route.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script context="module"> | ||
let load_calls = 0; | ||
export const load = () => { | ||
load_calls += 1; | ||
return { props: { calls: load_calls } }; | ||
}; | ||
</script> | ||
|
||
<script> | ||
import { onMount } from 'svelte'; | ||
import { page } from '$app/stores'; | ||
export let calls; | ||
const modal_contents = { | ||
'please-dont-show-me': { | ||
title: 'Oopsie' | ||
}, | ||
'please-dont-show-me-jr': { | ||
title: 'Oopsie Jr.' | ||
} | ||
}; | ||
let modal = undefined; | ||
const show_modal = () => { | ||
const hash = $page.url.hash.substring(1); | ||
modal = modal_contents[hash]; | ||
}; | ||
onMount(show_modal); | ||
</script> | ||
|
||
<svelte:window on:popstate={show_modal} /> | ||
|
||
<h1>{modal?.title ?? ''}</h1> | ||
<p>Loaded {calls} times.</p> |
3 changes: 3 additions & 0 deletions
3
packages/kit/test/apps/basics/src/routes/routing/prefetching/prefetched.json.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function get() { | ||
return { body: JSON.stringify('prefetched') }; | ||
} |
14 changes: 14 additions & 0 deletions
14
packages/kit/test/apps/basics/src/routes/routing/prefetching/prefetched.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script context="module"> | ||
/** @type {import('@sveltejs/kit').Load} */ | ||
export async function load({ fetch }) { | ||
const message = await fetch('/routing/prefetched.json').then(r => r.json()); | ||
return { props: { message } }; | ||
} | ||
</script> | ||
|
||
<script> | ||
/** @type {string} */ | ||
export let message; | ||
</script> | ||
|
||
<h1>{message}</h1> |
23 changes: 23 additions & 0 deletions
23
packages/kit/test/apps/options/source/pages/__layout.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script> | ||
import { | ||
goto, | ||
invalidate, | ||
prefetch, | ||
prefetchRoutes, | ||
beforeNavigate, | ||
afterNavigate | ||
} from '$app/navigation'; | ||
if (typeof window !== 'undefined') { | ||
Object.assign(window, { | ||
goto, | ||
invalidate, | ||
prefetch, | ||
prefetchRoutes, | ||
beforeNavigate, | ||
afterNavigate | ||
}); | ||
} | ||
</script> | ||
|
||
<slot /> |
1 change: 1 addition & 0 deletions
1
packages/kit/test/apps/options/source/pages/prefetching/index.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<a sveltekit:prefetch href="/path-base/prefetching/prefetched">click me</a> |
7 changes: 7 additions & 0 deletions
7
packages/kit/test/apps/options/source/pages/prefetching/prefetched.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export function get() { | ||
return { | ||
body: { | ||
message: 'prefetched' | ||
} | ||
}; | ||
} |
6 changes: 6 additions & 0 deletions
6
packages/kit/test/apps/options/source/pages/prefetching/prefetched.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<script> | ||
/** @type {string} */ | ||
export let message; | ||
</script> | ||
|
||
<h1>{message}</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters