mirror of
https://github.com/Kir-Antipov/mc-publish.git
synced 2024-11-22 00:11:02 -05:00
Made .redirect()
respect the provided options
This commit is contained in:
parent
78c153f935
commit
577191382f
1 changed files with 12 additions and 1 deletions
|
@ -173,7 +173,18 @@ export class HttpResponse {
|
|||
* @returns The newly created {@link HttpResponse} instance.
|
||||
*/
|
||||
static redirect(url: string | URL, options?: HttpResponseOptions): HttpResponse {
|
||||
return Response.redirect(asString(url), options?.status) as NodeFetchResponse;
|
||||
const headers = new NodeFetchHeaders(options?.headers);
|
||||
if (!headers.has("Location")) {
|
||||
headers.set("Location", asString(url));
|
||||
}
|
||||
|
||||
const redirectOptions = {
|
||||
headers,
|
||||
status: options.status ?? 302,
|
||||
statusText: options.statusText ?? "Found",
|
||||
} as HttpResponseOptions;
|
||||
|
||||
return new Response("", redirectOptions) as NodeFetchResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue