fix: percent-decode route params extracted from the pathname#223
Merged
Conversation
URLPattern matches against the encoded pathname and returns group values as-is, so params like /users/Jo%C3%A3o reached components and loaders in percent-encoded form. Decode each param value with decodeURIComponent, falling back to the raw value for malformed sequences. Closes #206 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B1GkQiKvX1SHpFs9ojyj1m
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 #206
Problem
Navigating to
/users/Jo%C3%A3owithpath: "/users/:name"yieldedparams.name === "Jo%C3%A3o"instead of"João".URLPattern.exec()matches against the percent-encoded pathname (location.pathnameis always in encoded form) and returns group values as-is, so any param containing spaces, unicode, or reserved characters reached loaders, actions, and components percent-encoded.Fix
extractParamsinpackages/router/src/core/matchRoutes.tsnow decodes each group value withdecodeURIComponent, falling back to the raw value for malformed sequences (e.g. a lone%) rather than failing the match. All matching paths (exact, fast prefix, and backtracking) funnel throughextractParams, so merged parent params are covered too.consumedPathnameintentionally stays encoded — it is used to slice the remaining pathname for child matching.Tests & docs
🤖 Generated with Claude Code
https://claude.ai/code/session_01B1GkQiKvX1SHpFs9ojyj1m
Generated by Claude Code