diff options
author | 2023-09-13 13:35:39 +0100 | |
---|---|---|
committer | 2023-09-13 05:35:39 -0700 | |
commit | c3455c0ceee6bbe399781819a42fff6cf24792e2 (patch) | |
tree | 203c044cedd5508a0ad2b3f42d50686ed6d0f049 /test/js/web/fetch/fetch.test.ts | |
parent | 9101774593288e32c7d9f0c77ab6f133628ebd10 (diff) | |
download | bun-c3455c0ceee6bbe399781819a42fff6cf24792e2.tar.gz bun-c3455c0ceee6bbe399781819a42fff6cf24792e2.tar.zst bun-c3455c0ceee6bbe399781819a42fff6cf24792e2.zip |
fix(node/fetch): Make data URL fetch consistent with node (#5126)
Diffstat (limited to 'test/js/web/fetch/fetch.test.ts')
-rw-r--r-- | test/js/web/fetch/fetch.test.ts | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/js/web/fetch/fetch.test.ts b/test/js/web/fetch/fetch.test.ts index aa44ee76a..4ef5d7bba 100644 --- a/test/js/web/fetch/fetch.test.ts +++ b/test/js/web/fetch/fetch.test.ts @@ -93,6 +93,30 @@ describe("fetch data urls", () => { expect(blob.type).toBe("text/plain;charset=utf-8"); expect(blob.text()).resolves.toBe("helloworld!"); }); + it("unstrict parsing of invalid URL characters", async () => { + var url = "data:application/json,{%7B%7D}"; + var res = await fetch(url); + expect(res.status).toBe(200); + expect(res.statusText).toBe("OK"); + expect(res.ok).toBe(true); + + var blob = await res.blob(); + expect(blob.size).toBe(4); + expect(blob.type).toBe("application/json;charset=utf-8"); + expect(blob.text()).resolves.toBe("{{}}"); + }); + it("unstrict parsing of double percent characters", async () => { + var url = "data:application/json,{%%7B%7D%%}%%"; + var res = await fetch(url); + expect(res.status).toBe(200); + expect(res.statusText).toBe("OK"); + expect(res.ok).toBe(true); + + var blob = await res.blob(); + expect(blob.size).toBe(9); + expect(blob.type).toBe("application/json;charset=utf-8"); + expect(blob.text()).resolves.toBe("{%{}%%}%%"); + }); it("data url (invalid)", async () => { var url = "data:Hello%2C%20World!"; expect(async () => { |