@remix-run/router 1.3.0-pre.2 → 1.3.0
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 +5 -13
- package/dist/router.cjs.js +13 -3
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +13 -3
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +13 -3
- 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 +13 -2
package/package.json
CHANGED
package/router.ts
CHANGED
|
@@ -1901,7 +1901,7 @@ export function createRouter(init: RouterInit): Router {
|
|
|
1901
1901
|
);
|
|
1902
1902
|
|
|
1903
1903
|
// Check if this an external redirect that goes to a new origin
|
|
1904
|
-
if (typeof window?.location !== "undefined") {
|
|
1904
|
+
if (isBrowser && typeof window?.location !== "undefined") {
|
|
1905
1905
|
let newOrigin = init.history.createURL(redirect.location).origin;
|
|
1906
1906
|
if (window.location.origin !== newOrigin) {
|
|
1907
1907
|
if (replace) {
|
|
@@ -2421,7 +2421,7 @@ export function createStaticHandler(
|
|
|
2421
2421
|
let matches = matchRoutes(dataRoutes, location, basename);
|
|
2422
2422
|
|
|
2423
2423
|
// SSR supports HEAD requests while SPA doesn't
|
|
2424
|
-
if (!isValidMethod(method) && method !== "head") {
|
|
2424
|
+
if (!isValidMethod(method) && method !== "head" && method !== "options") {
|
|
2425
2425
|
throw getInternalRouterError(405, { method });
|
|
2426
2426
|
} else if (!matches) {
|
|
2427
2427
|
throw getInternalRouterError(404, { pathname: location.pathname });
|
|
@@ -3115,6 +3115,17 @@ async function callLoaderOrAction(
|
|
|
3115
3115
|
}
|
|
3116
3116
|
|
|
3117
3117
|
location = createPath(resolvedLocation);
|
|
3118
|
+
} else if (!isStaticRequest) {
|
|
3119
|
+
// Strip off the protocol+origin for same-origin absolute redirects.
|
|
3120
|
+
// If this is a static reques, we can let it go back to the browser
|
|
3121
|
+
// as-is
|
|
3122
|
+
let currentUrl = new URL(request.url);
|
|
3123
|
+
let url = location.startsWith("//")
|
|
3124
|
+
? new URL(currentUrl.protocol + location)
|
|
3125
|
+
: new URL(location);
|
|
3126
|
+
if (url.origin === currentUrl.origin) {
|
|
3127
|
+
location = url.pathname + url.search + url.hash;
|
|
3128
|
+
}
|
|
3118
3129
|
}
|
|
3119
3130
|
|
|
3120
3131
|
// Don't process redirects in the router during static requests requests.
|