From e7e40302999a9a5528555cc17768709793d046a4 Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 15 May 2023 01:52:51 -0700 Subject: Fix bug with `req.url` set incorrectly (#2881) Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> --- test/js/web/fetch/fetch.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/js/web/fetch/fetch.test.ts') diff --git a/test/js/web/fetch/fetch.test.ts b/test/js/web/fetch/fetch.test.ts index c3327f37e..4d529b231 100644 --- a/test/js/web/fetch/fetch.test.ts +++ b/test/js/web/fetch/fetch.test.ts @@ -1165,3 +1165,18 @@ it("invalid header doesnt crash", () => { }), ).toThrow(); }); + +it("new Request(https://example.com, otherRequest) uses url from left instead of right", () => { + const req1 = new Request("http://localhost/abc", { + headers: { + foo: "bar", + }, + }); + + // Want to rewrite the URL with keeping header values + const req2 = new Request("http://localhost/def", req1); + + // Should be `http://localhost/def` But actual: http://localhost/abc + expect(req2.url).toBe("http://localhost/def"); + expect(req2.headers.get("foo")).toBe("bar"); +}); -- cgit v1.2.3