@remix-run/router 1.23.2 → 1.23.3

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/utils.d.ts CHANGED
@@ -439,6 +439,7 @@ export declare function resolveTo(toArg: To, routePathnames: string[], locationP
439
439
  * @private
440
440
  */
441
441
  export declare function getToPathname(to: To): string | undefined;
442
+ export declare const removeDoubleSlashes: (path: string) => string;
442
443
  /**
443
444
  * @private
444
445
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remix-run/router",
3
- "version": "1.23.2",
3
+ "version": "1.23.3",
4
4
  "description": "Nested/Data-driven/Framework-agnostic Routing",
5
5
  "keywords": [
6
6
  "remix",
package/router.ts CHANGED
@@ -50,6 +50,7 @@ import {
50
50
  joinPaths,
51
51
  matchRoutes,
52
52
  matchRoutesImpl,
53
+ removeDoubleSlashes,
53
54
  resolveTo,
54
55
  stripBasename,
55
56
  } from "./utils";
@@ -5186,7 +5187,7 @@ function normalizeRedirectLocation(
5186
5187
  }
5187
5188
  let isSameBasename = stripBasename(url.pathname, basename) != null;
5188
5189
  if (url.origin === currentUrl.origin && isSameBasename) {
5189
- return url.pathname + url.search + url.hash;
5190
+ return removeDoubleSlashes(url.pathname) + url.search + url.hash;
5190
5191
  }
5191
5192
  }
5192
5193
 
package/utils.ts CHANGED
@@ -545,6 +545,7 @@ export function matchRoutesImpl<
545
545
  rankRouteBranches(branches);
546
546
 
547
547
  let matches = null;
548
+ let decoded = decodePath(pathname);
548
549
  for (let i = 0; matches == null && i < branches.length; ++i) {
549
550
  // Incoming pathnames are generally encoded from either window.location
550
551
  // or from router.navigate, but we want to match against the unencoded
@@ -552,7 +553,6 @@ export function matchRoutesImpl<
552
553
  // encoded here but there also shouldn't be anything to decode so this
553
554
  // should be a safe operation. This avoids needing matchRoutes to be
554
555
  // history-aware.
555
- let decoded = decodePath(pathname);
556
556
  matches = matchRouteBranch<string, RouteObjectType>(
557
557
  branches[i],
558
558
  decoded,
@@ -1150,7 +1150,7 @@ export function resolvePath(to: To, fromPathname = "/"): Path {
1150
1150
  } else {
1151
1151
  if (toPathname.includes("//")) {
1152
1152
  let oldPathname = toPathname;
1153
- toPathname = toPathname.replace(/\/\/+/g, "/");
1153
+ toPathname = removeDoubleSlashes(toPathname);
1154
1154
  warning(
1155
1155
  false,
1156
1156
  `Pathnames cannot have embedded double slashes - normalizing ` +
@@ -1353,11 +1353,14 @@ export function getToPathname(to: To): string | undefined {
1353
1353
  : to.pathname;
1354
1354
  }
1355
1355
 
1356
+ export const removeDoubleSlashes = (path: string): string =>
1357
+ path.replace(/\/\/+/g, "/");
1358
+
1356
1359
  /**
1357
1360
  * @private
1358
1361
  */
1359
1362
  export const joinPaths = (paths: string[]): string =>
1360
- paths.join("/").replace(/\/\/+/g, "/");
1363
+ removeDoubleSlashes(paths.join("/"));
1361
1364
 
1362
1365
  /**
1363
1366
  * @private