Repository navigation
fix(Link): treat ? as a boundary in subroute matching - #1340
Merged
Merged
Conversation
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.
A page carrying query state (e.g.
~/items?filter=x) is still on its href's route, butmatch="subroute"rejected it: the character after the href was?, not/. A subroute below the href with a query (~/items/42?tab=log) already matched, which made the bug easy to miss — nav items highlighted on detail pages with query state but went dark on their own list page the moment it carried a filter in the URL. Route matching already tolerates the query string, so Link and Route disagreed about whether the same URL was "on" the route.The fix is one clause:
subrouteaccepts?as a boundary character alongside/.equalstays full-string equality (query-routed navs like~/docs?topic=avs?topic=bkeep exact matching) andprefixwas never affected.~/itemssubroute (before)~/items~/items?filter=x~/items/42?tab=log~/items-archiveLink.spec.tsxcovers all three match modes against exact/query/subroute/sibling-prefix urls, query-carrying hrefs, and theactiveoverride.litmus/bugs/link-active-query-string.jsrenders every scenario through both the old matcher (inlined as a subclass) and the fixed one side by side — flip the import inlitmus/index.jsto play with it.