@remix-run/router 1.23.0 → 1.23.1
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 +6 -0
- package/dist/router.cjs.js +22 -2
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +22 -2
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +22 -2
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/dist/utils.d.ts +1 -0
- package/package.json +1 -1
- package/utils.ts +26 -5
package/dist/utils.d.ts
CHANGED
|
@@ -399,6 +399,7 @@ export declare function decodePath(value: string): string;
|
|
|
399
399
|
* @private
|
|
400
400
|
*/
|
|
401
401
|
export declare function stripBasename(pathname: string, basename: string): string | null;
|
|
402
|
+
export declare const isAbsoluteUrl: (url: string) => boolean;
|
|
402
403
|
/**
|
|
403
404
|
* Returns a resolved path object relative to the given pathname.
|
|
404
405
|
*
|
package/package.json
CHANGED
package/utils.ts
CHANGED
|
@@ -1128,6 +1128,9 @@ export function stripBasename(
|
|
|
1128
1128
|
return pathname.slice(startIndex) || "/";
|
|
1129
1129
|
}
|
|
1130
1130
|
|
|
1131
|
+
const ABSOLUTE_URL_REGEX = /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;
|
|
1132
|
+
export const isAbsoluteUrl = (url: string) => ABSOLUTE_URL_REGEX.test(url);
|
|
1133
|
+
|
|
1131
1134
|
/**
|
|
1132
1135
|
* Returns a resolved path object relative to the given pathname.
|
|
1133
1136
|
*
|
|
@@ -1140,11 +1143,29 @@ export function resolvePath(to: To, fromPathname = "/"): Path {
|
|
|
1140
1143
|
hash = "",
|
|
1141
1144
|
} = typeof to === "string" ? parsePath(to) : to;
|
|
1142
1145
|
|
|
1143
|
-
let pathname
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1146
|
+
let pathname: string;
|
|
1147
|
+
if (toPathname) {
|
|
1148
|
+
if (isAbsoluteUrl(toPathname)) {
|
|
1149
|
+
pathname = toPathname;
|
|
1150
|
+
} else {
|
|
1151
|
+
if (toPathname.includes("//")) {
|
|
1152
|
+
let oldPathname = toPathname;
|
|
1153
|
+
toPathname = toPathname.replace(/\/\/+/g, "/");
|
|
1154
|
+
warning(
|
|
1155
|
+
false,
|
|
1156
|
+
`Pathnames cannot have embedded double slashes - normalizing ` +
|
|
1157
|
+
`${oldPathname} -> ${toPathname}`
|
|
1158
|
+
);
|
|
1159
|
+
}
|
|
1160
|
+
if (toPathname.startsWith("/")) {
|
|
1161
|
+
pathname = resolvePathname(toPathname.substring(1), "/");
|
|
1162
|
+
} else {
|
|
1163
|
+
pathname = resolvePathname(toPathname, fromPathname);
|
|
1164
|
+
}
|
|
1165
|
+
}
|
|
1166
|
+
} else {
|
|
1167
|
+
pathname = fromPathname;
|
|
1168
|
+
}
|
|
1148
1169
|
|
|
1149
1170
|
return {
|
|
1150
1171
|
pathname,
|