aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/fetch/fetch.test.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-05-15 01:52:51 -0700
committerGravatar GitHub <noreply@github.com> 2023-05-15 01:52:51 -0700
commite7e40302999a9a5528555cc17768709793d046a4 (patch)
treeefd01d134f2d59c8f69dc23def93a1484860b83f /test/js/web/fetch/fetch.test.ts
parentd3a72a1254075ddfa1f85959da0c2890693fe027 (diff)
downloadbun-e7e40302999a9a5528555cc17768709793d046a4.tar.gz
bun-e7e40302999a9a5528555cc17768709793d046a4.tar.zst
bun-e7e40302999a9a5528555cc17768709793d046a4.zip
Fix bug with `req.url` set incorrectly (#2881)
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'test/js/web/fetch/fetch.test.ts')
-rw-r--r--test/js/web/fetch/fetch.test.ts15
1 files changed, 15 insertions, 0 deletions
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");
+});