react-router 0.0.0-experimental-8bb3ffdf → 0.0.0-experimental-d90c8fb3

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/dist/main.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v0.0.0-experimental-8bb3ffdf
2
+ * React Router v0.0.0-experimental-d90c8fb3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /**
2
- * React Router v0.0.0-experimental-8bb3ffdf
2
+ * React Router v0.0.0-experimental-d90c8fb3
3
3
  *
4
4
  * Copyright (c) Remix Software Inc.
5
5
  *
@@ -323,7 +323,26 @@ function useRoutesImpl(routes, locationArg, dataRouterState, future) {
323
323
  location = locationFromContext;
324
324
  }
325
325
  let pathname = location.pathname || "/";
326
- let remainingPathname = parentPathnameBase === "/" ? pathname : pathname.slice(parentPathnameBase.length) || "/";
326
+ let remainingPathname = pathname;
327
+ if (parentPathnameBase !== "/") {
328
+ // Determine the remaining pathname by removing the # of URL segments the
329
+ // parentPathnameBase has, instead of removing based on character count.
330
+ // This is because we can't guarantee that incoming/outgoing encodings/
331
+ // decodings will match exactly.
332
+ // We decode paths before matching on a per-segment basis with
333
+ // decodeURIComponent(), but we re-encode pathnames via `new URL()` so they
334
+ // match what `window.location.pathname` would reflect. Those don't 100%
335
+ // align when it comes to encoded URI characters such as % and &.
336
+ //
337
+ // So we may end up with:
338
+ // pathname: "/descendant/a%25b/match"
339
+ // parentPathnameBase: "/descendant/a%b"
340
+ //
341
+ // And the direct substring removal approach won't work :/
342
+ let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
343
+ let segments = pathname.replace(/^\//, "").split("/");
344
+ remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
345
+ }
327
346
  let matches = matchRoutes(routes, {
328
347
  pathname: remainingPathname
329
348
  });