Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with pre-encoded param names not being properly decoded #11199

Merged
merged 9 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/fifty-pugs-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"react-router": patch
"@remix-run/router": patch
---

Fix encoding/decoding issues with pre-encoded dynamic parameter values
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,10 @@
"none": "50.4 kB"
},
"packages/react-router/dist/react-router.production.min.js": {
"none": "14.7 kB"
"none": "14.73 kB"
},
"packages/react-router/dist/umd/react-router.production.min.js": {
"none": "17.1 kB"
"none": "17.2 kB"
},
"packages/react-router-dom/dist/react-router-dom.production.min.js": {
"none": "16.9 kB"
Expand Down
4 changes: 4 additions & 0 deletions packages/react-router-dom-v5-compat/lib/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ export function StaticRouter({
},
encodeLocation(to: To) {
let href = typeof to === "string" ? to : createPath(to);
// Treating this as a full URL will strip any trailing spaces so we need to
// pre-encode them since they might be part of a matching splat param from
// an ancestor route
href = href.replace(/ $/, "%20");
let encoded = ABSOLUTE_URL_REGEX.test(href)
? new URL(href)
: new URL(href, "http://localhost");
Expand Down
Loading
Loading