Repository navigation
Match whole path segments in HardcodedRoutes - #1363
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
Author
|
I have signed the CLA. |
RaphaelFakhri
force-pushed
the
fix/hardcoded-routes-prefix
branch
from
October 29, 2026 13:03
7fe9813 to
46b0c2f
Compare
Author
|
Rebased onto |
This branch has not been deployed
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 are you adding in this PR?
Fixes #1362
HardcodedRoutesusedstartsWithto match a hardcoded path against the routes table, so a path that only shares a prefix with a route was reported./cartographywas reported as/cart,/searchingas/search, and/collections/all-shoeswas reported as/collections/allwith a suggestion to useroutes.all_products_collection_url, which links to a different page.The check now matches a route only when it is followed by the end of the value,
/,?or#. This applies to bothhref/actionattributes and thelink_tofilter./cart/change?line=1,/collections/{{ collection.handle }}and/cart#drawerare still reported.What's next? Any followup issues?
None.
What did you learn?
The routes table is iterated in reverse so longer routes such as
/collections/allwin over/collections. With the boundary check, a longer route that does not match on a segment boundary now falls back to the shorter one.Tophatting
Added a spec case with
/cartography,/searching,/accounting,/carts,/collections/all-shoesand/cart#drawer. Without the source change the case fails with 6 offenses instead of 2.Before you deploy
changeset