@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/package.json
CHANGED
package/router.ts
CHANGED
|
@@ -33,6 +33,7 @@ import {
|
|
|
33
33
|
joinPaths,
|
|
34
34
|
matchRoutes,
|
|
35
35
|
resolveTo,
|
|
36
|
+
stripBasename,
|
|
36
37
|
warning,
|
|
37
38
|
} from "./utils";
|
|
38
39
|
|
|
@@ -1935,15 +1936,17 @@ export function createRouter(init: RouterInit): Router {
|
|
|
1935
1936
|
redirectLocation,
|
|
1936
1937
|
"Expected a location on the redirect navigation"
|
|
1937
1938
|
);
|
|
1938
|
-
|
|
1939
1939
|
// Check if this an absolute external redirect that goes to a new origin
|
|
1940
1940
|
if (
|
|
1941
1941
|
ABSOLUTE_URL_REGEX.test(redirect.location) &&
|
|
1942
1942
|
isBrowser &&
|
|
1943
1943
|
typeof window?.location !== "undefined"
|
|
1944
1944
|
) {
|
|
1945
|
-
let
|
|
1946
|
-
|
|
1945
|
+
let url = init.history.createURL(redirect.location);
|
|
1946
|
+
let isDifferentBasename =
|
|
1947
|
+
stripBasename(url.pathname, init.basename || "/") == null;
|
|
1948
|
+
|
|
1949
|
+
if (window.location.origin !== url.origin || isDifferentBasename) {
|
|
1947
1950
|
if (replace) {
|
|
1948
1951
|
window.location.replace(redirect.location);
|
|
1949
1952
|
} else {
|
|
@@ -3173,14 +3176,15 @@ async function callLoaderOrAction(
|
|
|
3173
3176
|
|
|
3174
3177
|
location = createPath(resolvedLocation);
|
|
3175
3178
|
} else if (!isStaticRequest) {
|
|
3176
|
-
// Strip off the protocol+origin for same-origin absolute
|
|
3177
|
-
// If this is a static
|
|
3178
|
-
// as-is
|
|
3179
|
+
// Strip off the protocol+origin for same-origin + same-basename absolute
|
|
3180
|
+
// redirects. If this is a static request, we can let it go back to the
|
|
3181
|
+
// browser as-is
|
|
3179
3182
|
let currentUrl = new URL(request.url);
|
|
3180
3183
|
let url = location.startsWith("//")
|
|
3181
3184
|
? new URL(currentUrl.protocol + location)
|
|
3182
3185
|
: new URL(location);
|
|
3183
|
-
|
|
3186
|
+
let isSameBasename = stripBasename(url.pathname, basename) != null;
|
|
3187
|
+
if (url.origin === currentUrl.origin && isSameBasename) {
|
|
3184
3188
|
location = url.pathname + url.search + url.hash;
|
|
3185
3189
|
}
|
|
3186
3190
|
}
|