Repository navigation
fix(qwik-router): match routes that continue after a [...rest] segment - #9198
Merged
wmertens merged 1 commit intoOct 12, 2026
Merged
Conversation
The route trie ended every match at a `[...rest]` node: the rest always consumed all remaining segments, so routes below it such as `[...path]/product/[id]` were unreachable and every URL fell through to `[...path]`. Qwik City 1 matched these routes. A rest node with route segments below it now also yields partial matches that leave segments for its children, from the longest rest down to an empty one (`/product/1` gives `path: ''`). They rank below static and `[param]` matches like any rest match, and before the full rest, so the deeper route wins when both apply. The match walk advances by the segments each chain entry consumed instead of by chain index.
🦋 Changeset detectedLatest commit: 735ed65 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
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 |
@qwik.dev/core
@qwik.dev/router
@qwik.dev/utils
eslint-plugin-qwik
create-qwik
@qwik.dev/optimizer
@qwik.dev/devtools
@qwik.dev/mcp
commit: |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.

What is it?
Description
Routes that continue after a
[...rest]segment are unreachable in the v2 router. With/sports/balls/product/123always resolves to[...path]/index.tsxwithpath: 'sports/balls/product/123'. Qwik City 1 matched the second route withpath: 'sports/balls', id: '123'. We hit this while migrating a shop from Qwik City 1.19 to 2.0.0-rc.2, where every product URL lives below a category catch-all.The cause is in
packages/qwik-router/src/runtime/src/routing.ts:matchRestNodealways consumes all remaining segments withdone: true, andfindMatchChainthen ends the chain inmatchRestTail, so the children of a rest node are never tried. The backtracking from #8899 keeps this behaviour.The fix:
findChildAllalso yields partial rest matches that leave segments for its children, from the longest rest down to an empty one (/product/123givespath: '', as in v1). Rest nodes without children are unchanged.Restkind, so static and[param]matches still outrank them, and they come before the full rest so the deeper route wins when both reach a page.ChildMatchgets an optionalspan, andmatchRouteTreewalks the chain by its own index while advancingiby the consumed segments.findMatchChainreturns early when the rival tail is empty. This could not happen before, but with variable spans it would otherwise readbound[0]of an empty bound.Children below a rest node were unreachable before, so existing route trees match exactly as they did.
Checklist
pnpm changeTests: 7 new cases in
routing.unit.ts(4 of them fail onmain), all 801 qwik-router unit tests pass, and typecheck, eslint and prettier are clean.