Fix Location header not being cloned from Response.redirect() (#7402)

* Fix `Location` header not being cloned from `Response.redirect()`

* Fix was something else
This commit is contained in:
Ashcon Partovi
2023-12-01 16:35:28 -08:00
committed by GitHub
parent 52e1c2de08
commit dae985ab3c
2 changed files with 11 additions and 1 deletions

View File

@@ -1457,7 +1457,7 @@ void WebCore__FetchHeaders__put_(WebCore__FetchHeaders* headers, const ZigString
{
auto throwScope = DECLARE_THROW_SCOPE(global->vm());
WebCore::propagateException(*global, throwScope,
headers->set(Zig::toString(*arg1), Zig::toString(*arg2)));
headers->set(Zig::toString(*arg1), Zig::toStringCopy(*arg2)));
}
void WebCore__FetchHeaders__remove(WebCore__FetchHeaders* headers, const ZigString* arg1, JSC__JSGlobalObject* global)
{

View File

@@ -0,0 +1,10 @@
import { test, expect } from "bun:test";
test("Response.redirect clones string from Location header", () => {
const url = new URL("http://example.com");
url.hostname = "example1.com";
const { href } = url;
expect(href).toBe("http://example1.com/");
const response = Response.redirect(href);
expect(response.headers.get("Location")).toBe(href);
});