2023-12-07 08:10:38 +00:00
|
|
|
diff --git a/dist/router.cjs.js b/dist/router.cjs.js
|
|
|
|
index e9942914335495941766c9d1a63eacd42c67c6fc..2abfc267930e026e1a94f2c5c0fd6c5f88965802 100644
|
|
|
|
--- a/dist/router.cjs.js
|
|
|
|
+++ b/dist/router.cjs.js
|
|
|
|
@@ -1481,6 +1481,7 @@ const redirect = function redirect(url, init) {
|
|
|
|
}
|
|
|
|
let headers = new Headers(responseInit.headers);
|
|
|
|
headers.set("Location", url);
|
|
|
|
+ if (typeof init === "object" && init.replace) headers.set("X-Remix-Redirect-Replace", "true");
|
|
|
|
return new Response(null, _extends({}, responseInit, {
|
|
|
|
headers
|
|
|
|
}));
|
|
|
|
@@ -2491,7 +2492,7 @@ function createRouter(init) {
|
|
|
|
fetchRedirectIds.add(fetcherKey);
|
|
|
|
}
|
|
|
|
await startRedirectNavigation(state, redirect.result, {
|
|
|
|
- replace
|
|
|
|
+ replace: replace || redirect.result.replace
|
|
|
|
});
|
|
|
|
return {
|
|
|
|
shortCircuited: true
|
|
|
|
@@ -2698,7 +2699,9 @@ function createRouter(init) {
|
|
|
|
let fetcherKey = revalidatingFetchers[redirect.idx - matchesToLoad.length].key;
|
|
|
|
fetchRedirectIds.add(fetcherKey);
|
|
|
|
}
|
|
|
|
- return startRedirectNavigation(state, redirect.result);
|
|
|
|
+ return startRedirectNavigation(state, redirect.result, {
|
|
|
|
+ replace: redirect.result.replace
|
|
|
|
+ });
|
|
|
|
}
|
2024-05-29 23:28:28 +00:00
|
|
|
|
2023-12-07 08:10:38 +00:00
|
|
|
// Process and commit output from loaders
|
|
|
|
@@ -4121,6 +4124,7 @@ async function callLoaderOrAction(type, request, match, matches, manifest, mapRo
|
|
|
|
type: ResultType.redirect,
|
|
|
|
status,
|
|
|
|
location,
|
|
|
|
+ replace: result.headers.get("X-Remix-Redirect-Replace") !== null,
|
|
|
|
revalidate: result.headers.get("X-Remix-Revalidate") !== null,
|
|
|
|
reloadDocument: result.headers.get("X-Remix-Reload-Document") !== null
|
|
|
|
};
|
|
|
|
diff --git a/dist/utils.d.ts b/dist/utils.d.ts
|
|
|
|
index f393b6ca4f4092d1fe83348d8b2f1598bc63ef88..ef3eacc16b96c5d955c3beb202434bf491c0deed 100644
|
|
|
|
--- a/dist/utils.d.ts
|
|
|
|
+++ b/dist/utils.d.ts
|
|
|
|
@@ -38,6 +38,7 @@ export interface RedirectResult {
|
|
|
|
location: string;
|
|
|
|
revalidate: boolean;
|
|
|
|
reloadDocument?: boolean;
|
|
|
|
+ replace?: boolean;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Unsuccessful result from a loader or action
|
|
|
|
@@ -458,7 +459,9 @@ export declare class DeferredData {
|
|
|
|
}
|
|
|
|
export type DeferFunction = (data: Record<string, unknown>, init?: number | ResponseInit) => DeferredData;
|
|
|
|
export declare const defer: DeferFunction;
|
|
|
|
-export type RedirectFunction = (url: string, init?: number | ResponseInit) => Response;
|
|
|
|
+export type RedirectFunction = (url: string, init?: number | (ResponseInit & {
|
|
|
|
+ replace?: boolean;
|
|
|
|
+})) => Response;
|
|
|
|
/**
|
|
|
|
* A redirect response. Sets the status code and the `Location` header.
|
2024-05-29 23:28:28 +00:00
|
|
|
* Defaults to "302 Found".
|