Fix the most specific matching route when using pathless routes#11138
Merged
Fix the most specific matching route when using pathless routes#11138
Conversation
fzaninotto
reviewed
Jan 26, 2026
Comment on lines
+1499
to
+1510
| <LinkBase | ||
| to="/users/john_doe" | ||
| style={{ marginRight: 10 }} | ||
| > | ||
| User | ||
| </LinkBase> | ||
| <LinkBase | ||
| to="/users/jane_doe/block" | ||
| style={{ marginRight: 10 }} | ||
| > | ||
| Block a user | ||
| </LinkBase> |
Member
There was a problem hiding this comment.
shouldn't these two routes share the same root? i.e. either john_doe or jane_doe? Otherwise I don't see the point of the test.
Contributor
Author
There was a problem hiding this comment.
It doesn't actually matter. What we're testing here is that /users/:username/block route is working as expected (meaning it should show the "Block a user" and not the catch-all "Users View"). The shared root of the two routes is /users and that's enough. But I can use john_doe in the two links if you think it's more logical.
djhi
approved these changes
Jan 27, 2026
WiXSL
requested changes
Jan 27, 2026
742a5b0 to
e53c695
Compare
WiXSL
requested changes
Jan 27, 2026
WiXSL
approved these changes
Jan 27, 2026
djhi
approved these changes
Jan 29, 2026
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.
Problem
In #11102, @WiXSL pointed the following (#11102 (comment)):
After more investigations, he was right. When a more specific route was defined after a catch-all route nested in a pathless route, the catch-all route was returned before the more specific route was even evaluated. In the following example, the catch-all route
/users/*was matched when the pathname was/users/jane_doe/block.Solution
Extract the matching route finding algorithm in a function, and call it recursively with the children of the pathless route to always find the most specific route.
How To Test
Additional Checks
masterfor a bugfix or a documentation fix, ornextfor a feature