react-router 6.22.0-pre.0 → 6.22.1-pre.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,11 +1,19 @@
1
1
  # `react-router`
2
2
 
3
- ## 6.22.0-pre.0
3
+ ## 6.22.1-pre.0
4
4
 
5
5
  ### Patch Changes
6
6
 
7
+ - Fix encoding/decoding issues with pre-encoded dynamic parameter values ([#11199](https://github.com/remix-run/react-router/pull/11199))
7
8
  - Updated dependencies:
8
- - `@remix-run/router@1.15.0-pre.0`
9
+ - `@remix-run/router@1.15.1-pre.0`
10
+
11
+ ## 6.22.0
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies:
16
+ - `@remix-run/router@1.15.0`
9
17
 
10
18
  ## 6.21.3
11
19
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v6.22.0-pre.0
2
+ * React Router v6.22.1-pre.0
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -372,7 +372,26 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
372
372
  location = locationFromContext;
373
373
  }
374
374
  let pathname = location.pathname || "/";
375
- let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
375
+ let remainingPathname = pathname;
376
+ if (parentPathnameBase !== "/") {
377
+ // Determine the remaining pathname by removing the # of URL segments the
378
+ // parentPathnameBase has, instead of removing based on character count.
379
+ // This is because we can't guarantee that incoming/outgoing encodings/
380
+ // decodings will match exactly.
381
+ // We decode paths before matching on a per-segment basis with
382
+ // decodeURIComponent(), but we re-encode pathnames via `new URL()` so they
383
+ // match what `window.location.pathname` would reflect. Those don't 100%
384
+ // align when it comes to encoded URI characters such as % and &.
385
+ //
386
+ // So we may end up with:
387
+ // pathname: "/descendant/a%25b/match"
388
+ // parentPathnameBase: "/descendant/a%b"
389
+ //
390
+ // And the direct substring removal approach won't work :/
391
+ let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
392
+ let segments = pathname.replace(/^\//, "").split("/");
393
+ remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
394
+ }
376
395
  let matches = matchRoutes(routes, {
377
396
  pathname: remainingPathname
378
397
  });