Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/loud-ghosts-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': fix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fyi, this needed to be patch. releases are failing because this is an invalid value: #9365

---

fix: don't skip required parameters after missing optional parameters
2 changes: 1 addition & 1 deletion packages/kit/src/utils/routing.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export function exec(match, params, matchers) {
// and the next value is defined, otherwise the buffer will cause us to skip values
const next_param = params[i + 1];
const next_value = values[i + 1];
if (next_param && !next_param.rest && next_value) {
if (next_param && !next_param.rest && next_param.optional && next_value) {
buffered = 0;
}
continue;
Expand Down
5 changes: 5 additions & 0 deletions packages/kit/src/utils/routing.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@ const exec_tests = [
route: '/[[slug1=doesntmatch]]/[[slug2=matches]]/constant/[[slug3=matches]]',
path: '/b/constant/c',
expected: { slug2: 'b', slug3: 'c' }
},
{
route: '/[[slug1=doesntmatch]]/[slug2=matches]/[slug3]',
path: '/a/b/c',
expected: undefined
}
];

Expand Down