@remix-run/router 1.23.1 → 1.23.2
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 +18 -4
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +18 -4
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +18 -4
- 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/package.json +1 -1
- package/router.ts +33 -3
package/CHANGELOG.md
CHANGED
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.23.
|
|
2
|
+
* @remix-run/router v1.23.2
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -2531,7 +2531,7 @@ function createRouter(init) {
|
|
|
2531
2531
|
// If the user didn't explicity indicate replace behavior, replace if
|
|
2532
2532
|
// we redirected to the exact same location we're currently at to avoid
|
|
2533
2533
|
// double back-buttons
|
|
2534
|
-
let location = normalizeRedirectLocation(result.response.headers.get("Location"), new URL(request.url), basename);
|
|
2534
|
+
let location = normalizeRedirectLocation(result.response.headers.get("Location"), new URL(request.url), basename, init.history);
|
|
2535
2535
|
replace = location === state.location.pathname + state.location.search;
|
|
2536
2536
|
}
|
|
2537
2537
|
await startRedirectNavigation(request, result, true, {
|
|
@@ -3171,7 +3171,7 @@ function createRouter(init) {
|
|
|
3171
3171
|
}
|
|
3172
3172
|
let location = redirect.response.headers.get("Location");
|
|
3173
3173
|
invariant(location, "Expected a Location header on the redirect Response");
|
|
3174
|
-
location = normalizeRedirectLocation(location, new URL(request.url), basename);
|
|
3174
|
+
location = normalizeRedirectLocation(location, new URL(request.url), basename, init.history);
|
|
3175
3175
|
let redirectLocation = createLocation(state.location, location, {
|
|
3176
3176
|
_isRedirect: true
|
|
3177
3177
|
});
|
|
@@ -4954,16 +4954,30 @@ function normalizeRelativeRoutingRedirectResponse(response, request, routeId, ma
|
|
|
4954
4954
|
}
|
|
4955
4955
|
return response;
|
|
4956
4956
|
}
|
|
4957
|
-
function normalizeRedirectLocation(location, currentUrl, basename) {
|
|
4957
|
+
function normalizeRedirectLocation(location, currentUrl, basename, historyInstance) {
|
|
4958
|
+
// Match Chrome's behavior:
|
|
4959
|
+
// https://github.com/chromium/chromium/blob/216dbeb61db0c667e62082e5f5400a32d6983df3/content/public/common/url_utils.cc#L82
|
|
4960
|
+
let invalidProtocols = ["about:", "blob:", "chrome:", "chrome-untrusted:", "content:", "data:", "devtools:", "file:", "filesystem:",
|
|
4961
|
+
// eslint-disable-next-line no-script-url
|
|
4962
|
+
"javascript:"];
|
|
4958
4963
|
if (ABSOLUTE_URL_REGEX.test(location)) {
|
|
4959
4964
|
// Strip off the protocol+origin for same-origin + same-basename absolute redirects
|
|
4960
4965
|
let normalizedLocation = location;
|
|
4961
4966
|
let url = normalizedLocation.startsWith("//") ? new URL(currentUrl.protocol + normalizedLocation) : new URL(normalizedLocation);
|
|
4967
|
+
if (invalidProtocols.includes(url.protocol)) {
|
|
4968
|
+
throw new Error("Invalid redirect location");
|
|
4969
|
+
}
|
|
4962
4970
|
let isSameBasename = stripBasename(url.pathname, basename) != null;
|
|
4963
4971
|
if (url.origin === currentUrl.origin && isSameBasename) {
|
|
4964
4972
|
return url.pathname + url.search + url.hash;
|
|
4965
4973
|
}
|
|
4966
4974
|
}
|
|
4975
|
+
try {
|
|
4976
|
+
let url = historyInstance.createURL(location);
|
|
4977
|
+
if (invalidProtocols.includes(url.protocol)) {
|
|
4978
|
+
throw new Error("Invalid redirect location");
|
|
4979
|
+
}
|
|
4980
|
+
} catch (e) {}
|
|
4967
4981
|
return location;
|
|
4968
4982
|
}
|
|
4969
4983
|
|