Repository navigation
fix(react): Parameterize React Router transactions with encoded params - #25639
Open
seongwon030 wants to merge 1 commit into
Open
seongwon030 wants to merge 1 commit into
seongwon030 wants to merge 1 commit into
Conversation
`location.pathname` is percent-encoded, but React Router decodes the pathname before matching, so `RouteMatch.pathname` and `pathnameBase` are decoded. The instrumentation compared the two with plain string equality, so a route like `/clubs/:clubId` visited as `/clubs/%ED%95%9C%EA%B8%80` never matched and the transaction fell back to the raw URL with source `url`. Decode both sides, segment by segment like React Router's `decodePath`, before comparing in `getNormalizedName` and before stripping `pathnameBase` for descendant routes.
seongwon030
requested review from
chargome and
s1gr1d
and removed request for
a team
October 22, 2026 03:18
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.
Closes #25638
pnpm run lint) & (pnpm run test).location.pathnameis percent-encoded, but React Router decodes the pathname before matching (decodePath), soRouteMatch.pathnameandpathnameBaseare decoded. The React Router instrumentation compared the two with plain string equality, so a route like/clubs/:clubIdvisited as/clubs/%ED%95%9C%EA%B8%80never matched and the transaction fell back to the raw URL with sourceurl. Every non-ASCII parameter value became its own transaction name. Descendant routes (<Routes>nested under a/*route) produced the raw URL with sourceroute.This adds
decodePathname, the same segment-wise algorithm as React Router'sdecodePath, and applies it to both sides of the comparison ingetNormalizedNameand of thepathnameBasestripping for descendant routes. Decoding both sides keeps percent-encoded basenames and older 6.x routers working: before 6.22.1matchRoutesmatched against the raw pathname or useddecodeURI, so there the branch pathname is the side that is still encoded. A value that still looks percent-encoded after one decode (a literal%41) is decoded once more; such values were not parameterized before either.Validation (in
packages/react):vitest runon the React Router suites (react-router,reactrouterv6,reactrouter-descendant-routes,reactrouter-cross-usage,reactrouter-compat-utils/*): 276 tests passed, including the new onesdecodePathname,getNormalizedName,rebuildRoutePathFromAllRoutes, v7 pageload/navigation and v6 descendant-route tests fail without the fixpnpm run lintclean;oxfmt --checkpassed on the changed files