Skip to content
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

fix: rest matcher skipped if optional is empty #10020

Merged
merged 2 commits into from
Jun 6, 2023

Conversation

pzerelles
Copy link
Contributor

I found that since version 1.3.6 a matcher on a rest parameter is not called anymore if an optional parameter before it is empty. I'm using the optional for localization and the following rest parameter has a matcher.

Example route:
[[locale=locale]]/[...rest=page]

For /en/test, the page matcher will be called with param test.
For /test, the page matcher was not called since version 1.3.6.

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests

  • Run the tests with pnpm test and lint the project with pnpm lint and pnpm check

Changesets

  • If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running pnpm changeset and following the prompts. Changesets that add features should be minor and those that fix bugs should be patch. Please prefix changeset messages with feat:, fix:, or chore:.

Sorry, something went wrong.

@changeset-bot
Copy link

changeset-bot bot commented May 23, 2023

🦋 Changeset detected

Latest commit: 72e580a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@sveltejs/kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@elliott-with-the-longest-name-on-github
Copy link
Contributor

Pretty sure this more comprehensive PR fixes this issue as well: #9987

@elliott-with-the-longest-name-on-github
Copy link
Contributor

Hmm, maybe not -- not sure -- either way, let's not add integration tests for this. There's a routing.spec.ts file with unit tests for exec that you can use to test this behavior. It runs much faster than integration tests and I don't think we get any meaningfully better coverage by using integration tests in this case!

@pzerelles
Copy link
Contributor Author

Changed integration test to unit test. I'm pretty sure that #9987 does not fix that case.

@benmccann
Copy link
Member

@pzerelles would you mind addressing the merge conflict that's shown up? It's a result of me merging #9987

@benmccann
Copy link
Member

Pretty sure this more comprehensive PR fixes this issue as well: #9987

The unit test here fails without the change that's here, so I'm going to say this change is still necessary and go ahead and merge it.

I cut a release with #9987 in it so that the two PRs will be in separate releases. That way if anyone encounters any regressions related to routing changes it will be easier to tell which PR affected it

@benmccann benmccann merged commit 2046ec0 into sveltejs:master Jun 6, 2023
@github-actions github-actions bot mentioned this pull request Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants