aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/fetch/fetch.test.ts
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2023-07-28 15:44:05 -0700
committerGravatar GitHub <noreply@github.com> 2023-07-28 15:44:05 -0700
commit7a1ebec26fc1a3f480fca5e5508d5ceda5a2ebcf (patch)
treed307006c2b72cf0d1a14dcbcd003225fde993414 /test/js/web/fetch/fetch.test.ts
parente7c80b90b81847be158a6e87d0200a8df4121a37 (diff)
downloadbun-7a1ebec26fc1a3f480fca5e5508d5ceda5a2ebcf.tar.gz
bun-7a1ebec26fc1a3f480fca5e5508d5ceda5a2ebcf.tar.zst
bun-7a1ebec26fc1a3f480fca5e5508d5ceda5a2ebcf.zip
Support file: URLs in `fetch` (#3858)
* Support file: URLs in `fetch` * Update url.zig --------- 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.ts10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/js/web/fetch/fetch.test.ts b/test/js/web/fetch/fetch.test.ts
index 768818420..d7fc87ade 100644
--- a/test/js/web/fetch/fetch.test.ts
+++ b/test/js/web/fetch/fetch.test.ts
@@ -1203,3 +1203,13 @@ it("new Request(https://example.com, otherRequest) uses url from left instead of
expect(req2.url).toBe("http://localhost/def");
expect(req2.headers.get("foo")).toBe("bar");
});
+
+it("fetch() file:// works", async () => {
+ expect(await (await fetch(import.meta.url)).text()).toEqual(await Bun.file(import.meta.path).text());
+ expect(await (await fetch(new URL("fetch.test.ts", import.meta.url))).text()).toEqual(
+ await Bun.file(Bun.fileURLToPath(new URL("fetch.test.ts", import.meta.url))).text(),
+ );
+ expect(await (await fetch(new URL("file with space in the name.txt", import.meta.url))).text()).toEqual(
+ await Bun.file(Bun.fileURLToPath(new URL("file with space in the name.txt", import.meta.url))).text(),
+ );
+});