@remix-run/router 1.3.3-pre.0 → 1.3.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/CHANGELOG.md +3 -2
- package/dist/router.cjs.js +9 -7
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +9 -7
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +9 -7
- 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 +11 -7
package/dist/router.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.3.3
|
|
2
|
+
* @remix-run/router v1.3.3
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -2508,9 +2508,10 @@ function createRouter(init) {
|
|
|
2508
2508
|
invariant(redirectLocation, "Expected a location on the redirect navigation"); // Check if this an absolute external redirect that goes to a new origin
|
|
2509
2509
|
|
|
2510
2510
|
if (ABSOLUTE_URL_REGEX.test(redirect.location) && isBrowser && typeof ((_window = window) == null ? void 0 : _window.location) !== "undefined") {
|
|
2511
|
-
let
|
|
2511
|
+
let url = init.history.createURL(redirect.location);
|
|
2512
|
+
let isDifferentBasename = stripBasename(url.pathname, init.basename || "/") == null;
|
|
2512
2513
|
|
|
2513
|
-
if (window.location.origin !==
|
|
2514
|
+
if (window.location.origin !== url.origin || isDifferentBasename) {
|
|
2514
2515
|
if (replace) {
|
|
2515
2516
|
window.location.replace(redirect.location);
|
|
2516
2517
|
} else {
|
|
@@ -3545,13 +3546,14 @@ async function callLoaderOrAction(type, request, match, matches, basename, isSta
|
|
|
3545
3546
|
|
|
3546
3547
|
location = createPath(resolvedLocation);
|
|
3547
3548
|
} else if (!isStaticRequest) {
|
|
3548
|
-
// Strip off the protocol+origin for same-origin absolute
|
|
3549
|
-
// If this is a static
|
|
3550
|
-
// as-is
|
|
3549
|
+
// Strip off the protocol+origin for same-origin + same-basename absolute
|
|
3550
|
+
// redirects. If this is a static request, we can let it go back to the
|
|
3551
|
+
// browser as-is
|
|
3551
3552
|
let currentUrl = new URL(request.url);
|
|
3552
3553
|
let url = location.startsWith("//") ? new URL(currentUrl.protocol + location) : new URL(location);
|
|
3554
|
+
let isSameBasename = stripBasename(url.pathname, basename) != null;
|
|
3553
3555
|
|
|
3554
|
-
if (url.origin === currentUrl.origin) {
|
|
3556
|
+
if (url.origin === currentUrl.origin && isSameBasename) {
|
|
3555
3557
|
location = url.pathname + url.search + url.hash;
|
|
3556
3558
|
}
|
|
3557
3559
|
} // Don't process redirects in the router during static requests requests.
|