aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/fetch/fetch.test.ts
diff options
context:
space:
mode:
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(),
+ );
+});