Skip to content

Commit

Permalink
Fix issues with pre-encoded param names not being properly decoded (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Feb 6, 2024
1 parent 7c0bfde commit 241f2d4
Show file tree
Hide file tree
Showing 8 changed files with 214 additions and 140 deletions.
6 changes: 6 additions & 0 deletions .changeset/fifty-pugs-boil.md
@@ -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
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": "17.0 kB"
Expand Down
4 changes: 4 additions & 0 deletions packages/react-router-dom-v5-compat/lib/components.tsx
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

0 comments on commit 241f2d4

Please sign in to comment.