Rest Route Params "Stealing" Previous Dynamic Segment Param
See original GitHub issueDescribe the bug Adding rest route params appears to steal some of previous dynamic segment parameter
This would prevent the route shown in the docs from working
/[org]/[repo]/tree/[branch]/[...file]
would only get the first character for the [branch]
param.
Example:
Given a route structure containing:
/fixed/index.svelte
<script>
import { page } from '$app/stores'
</script>
<p>/fixed</p>
<pre>{JSON.stringify($page, null, ' ')}</pre>
/fixed/[dynamic]/index.svelte
<script>
import { page } from '$app/stores'
</script>
<p>/fixed/[dynamic]</p>
<pre>{JSON.stringify($page, null, ' ')}</pre>
/fixed/[dynamic]/[…rest].svelte
<script>
import { page } from '$app/stores'
</script>
<p>/fixed/[dynamic]/[...rest]</p>
<pre>{JSON.stringify($page, null, ' ')}</pre>
… works as expected until the rest route is reached, for example:
/fixed
{
"host": "localhost:3000",
"path": "/fixed",
"query": {},
"params": {}
}
http://localhost:3000/fixed/one
/fixed/[dynamic]
{
"host": "localhost:3000",
"path": "/fixed/one",
"query": {},
"params": {
"dynamic": "one"
}
}
http://localhost:3000/fixed/one/two/three
/fixed/[dynamic]/[...rest]
{
"host": "localhost:3000",
"path": "/fixed/one/two/three",
"query": {},
"params": {
"dynamic": "o",
"rest": "ne/two/three"
}
}
Note the “dynamic” parameter which is now o
with the rest parameter stealing the ne
I also tried using /[...rest]/index.svelte
as well (same result)
To Reproduce Example repo: https://github.com/CaptainCodeman/svelte-kit-rest-routing
Expected behavior I expected the final route to produce:
{
"host": "localhost:3000",
"path": "/fixed/one/two/three",
"query": {},
"params": {
"dynamic": "one",
"rest": "/two/three"
}
}
Information about your SvelteKit Installation:
Diagnostics
System: OS: macOS 11.2.3 CPU: (8) x64 Intel® Core™ i7-4850HQ CPU @ 2.30GHz Memory: 1.25 GB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 14.15.1 - /usr/local/bin/node npm: 7.8.0 - /usr/local/bin/npm Browsers: Chrome: 89.0.4389.114 Firefox: 83.0 Safari: 14.0.3 npmPackages: @sveltejs/kit: next => 1.0.0-next.71 svelte: ^3.29.0 => 3.37.0 vite: ^2.1.0 => 2.1.5
-
Your browser Chrome 89
-
Your adapter (e.g. Node, static, Vercel, Begin, etc…)
-
Node
Severity No immediate urgency
Additional context The dynamic segment is the context for a selected project, the rest parameters are a folder path in the context of the app.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:9 (7 by maintainers)
Top GitHub Comments
closed via #1128, thanks
It’s been released now, and I can confirm that it fixes the bug. I took my bug reproduction project, ran
pnpm update
in it to pull in Svelte-Kit version1.0.0-next.84
and thelocalhost:3000/one-food/two-foo/three
route now returns a 404 as it should.