-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Describe the bug
Given a [[lang=lang]]/[...path] route, kit will fail to catch non-matched URLs with the rest parameters route.
The same doesn't happen if the optional route is followed by a static one: [[lang=lang]]/t/[...path].
// params/lang.js
export const match = (param) => {
return ['fr', 'de'].includes(param);
};I would expect:
/home -> { lang: undefined, path: 'home' } -> gives 404
/de/home -> { lang: 'de', path: 'home' } -> correct
In the [[lang=lang]]/t/[...path] scenario, it works as expected:
/t/home -> { lang: undefined, path: 'home' } -> correct
/de/t/home -> { lang: 'de', path: 'home' } -> correct
A common use case for this would be an i18n site with dynamic pages being served by a CMS.
Reproduction
Here's a stackblitz reproducing the issue:
https://stackblitz.com/edit/sveltejs-kit-template-default-4srbff?file=src/routes/+layout.svelte
And here's another one showing the correct expected behaviour by placing a static route after the optional one:
https://stackblitz.com/edit/sveltejs-kit-template-default-a3vmdd?file=src/routes/+layout.svelte
Logs
No response
System Info
System:
OS: macOS 13.0
CPU: (8) arm64 Apple M2
Memory: 50.08 MB / 16.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.10.0 - ~/.nvm/versions/node/v18.10.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v18.10.0/bin/npm
Watchman: 2022.10.03.00 - /opt/homebrew/bin/watchman
Browsers:
Brave Browser: 107.1.45.116
Chrome: 107.0.5304.87
Firefox: 106.0.5
Safari: 16.1
npmPackages:
@sveltejs/adapter-auto: next => 1.0.0-next.87
@sveltejs/kit: 1.0.0-next.538 => 1.0.0-next.538
svelte: ^3.44.0 => 3.52.0
vite: ^3.1.0 => 3.2.3Severity
serious, but I can work around it
Additional Information
No response