Repository navigation
feat: provide match function to allow the opposite of resolve #14997
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
cf61978
feat: provide match function to allow the opposite of resolve
hmnd d02f58d
use get_navigation_intent and reroute hook
hmnd 61870b0
support passing url to match
hmnd f4197f5
fix types
hmnd 2534e43
extract route matching into find_route
hmnd d8f31c1
clean up
hmnd aec93c4
Merge branch 'main' into push-mxvotmyyvmzn
teemingc 92581ce
Merge branch 'main' into push-mxvotmyyvmzn
hmnd 2cb375c
Merge branch 'main' into push-mxvotmyyvmzn
teemingc 81192d8
Merge branch 'main' into push-mxvotmyyvmzn
hmnd c081980
Merge branch 'main' into push-mxvotmyyvmzn
teemingc 7ef251d
Merge branch 'main' into push-mxvotmyyvmzn
PatrickG e5c5f49
Merge branch 'main' into push-mxvotmyyvmzn
teemingc 74dc3db
Apply suggestion from @teemingc
teemingc 231c584
standardize internal origin to http://internal
hmnd 26b5933
handle server match reroute failures
hmnd 71c9955
improve match documentation example
hmnd ca85247
tests: add match base path and search param coverage
hmnd 1ccc74c
touch up
hmnd 99f4abe
Merge branch 'main' into push-mxvotmyyvmzn
hmnd a93eb14
update generated types
hmnd 6b65a35
Apply suggestion from @teemingc
teemingc 61c2bda
generate types
teemingc dc01e8b
Merge branch 'main' into push-mxvotmyyvmzn
teemingc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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': minor | ||
| --- | ||
|
|
||
| feat: `match` function to map a path back to a route id and params |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
12 changes: 12 additions & 0 deletions
12
packages/kit/test/apps/basics/src/routes/match/+page.server.js
This file contains hidden or 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,12 @@ | ||
| import { match } from '$app/paths'; | ||
| import { testPaths } from './const'; | ||
|
|
||
| export async function load() { | ||
| const serverResults = await Promise.all( | ||
| testPaths.map(async (path) => ({ path, result: await match(path) })) | ||
| ); | ||
|
|
||
| return { | ||
| serverResults | ||
| }; | ||
| } |
34 changes: 34 additions & 0 deletions
34
packages/kit/test/apps/basics/src/routes/match/+page.svelte
This file contains hidden or 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,34 @@ | ||
| <script> | ||
| import { match } from '$app/paths'; | ||
| import { onMount } from 'svelte'; | ||
| import { testPaths } from './const'; | ||
|
|
||
| let { data } = $props(); | ||
|
|
||
| const clientResults = $state([]); | ||
|
|
||
| onMount(async () => { | ||
| for (const path of testPaths) { | ||
| const result = await match(path); | ||
| clientResults.push({ path, result }); | ||
| } | ||
| }); | ||
| </script> | ||
|
|
||
| <h1>Match Test</h1> | ||
|
|
||
| <div id="server-results"> | ||
| {#each data.serverResults as { path, result }} | ||
| <div class="result" data-path={path}> | ||
| {JSON.stringify(result)} | ||
| </div> | ||
| {/each} | ||
| </div> | ||
|
|
||
| <div id="client-results"> | ||
| {#each clientResults as { path, result }} | ||
| <div class="result" data-path={path}> | ||
| {JSON.stringify(result)} | ||
| </div> | ||
| {/each} | ||
| </div> |
This file contains hidden or 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 const testPaths = [ | ||
| '/match/load/foo', | ||
| '/match/slug/test-slug', | ||
| '/match/slug/test-slug?from=query', | ||
| '/match/not-a-real-route-that-exists', | ||
| '/reroute/basic/a' | ||
| ]; |
1 change: 1 addition & 0 deletions
1
packages/kit/test/apps/basics/src/routes/match/load/foo/+page.svelte
This file contains hidden or 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 @@ | ||
| bar |
1 change: 1 addition & 0 deletions
1
packages/kit/test/apps/basics/src/routes/match/slug/[slug]/+page.svelte
This file contains hidden or 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 @@ | ||
| slug |
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.