diff options
author | 2022-11-09 15:11:14 -0800 | |
---|---|---|
committer | 2022-11-09 15:11:14 -0800 | |
commit | da257336b0b70df8c31da647496899cf70670000 (patch) | |
tree | 6baca9ead683633e8feac503529d94e8a565445c /test/bun.js | |
parent | 565996a087df6d06b2b5109b6825c720d4c8b168 (diff) | |
download | bun-da257336b0b70df8c31da647496899cf70670000.tar.gz bun-da257336b0b70df8c31da647496899cf70670000.tar.zst bun-da257336b0b70df8c31da647496899cf70670000.zip |
Fix #1354
Diffstat (limited to 'test/bun.js')
-rw-r--r-- | test/bun.js/serve.test.ts | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/test/bun.js/serve.test.ts b/test/bun.js/serve.test.ts index 9f351e93d..c033aaeb3 100644 --- a/test/bun.js/serve.test.ts +++ b/test/bun.js/serve.test.ts @@ -41,13 +41,35 @@ it("request.url should log successfully", async () => { return new Response(file(fixture)); }, }); - expected = `http://${server.hostname}:${server.port}/helloooo`; + expected = `http://localhost:${server.port}/helloooo`; const response = await fetch(expected); expect(response.url).toBe(expected); expect(await response.text()).toBe(textToExpect); server.stop(); }); +it("request.url should be based on the Host header", async () => { + const fixture = resolve(import.meta.dir, "./fetch.js.txt"); + const textToExpect = readFileSync(fixture, "utf-8"); + var expected; + const server = serve({ + port: port++, + fetch(req) { + expect(req.url).toBe("http://example.com/helloooo"); + return new Response(file(fixture)); + }, + }); + expected = `http://${server.hostname}:${server.port}/helloooo`; + const response = await fetch(expected, { + headers: { + Host: "example.com", + }, + }); + expect(response.url).toBe(expected); + expect(await response.text()).toBe(textToExpect); + server.stop(); +}); + describe("streaming", () => { describe("error handler", () => { it("throw on pull reports an error and close the connection", async () => { |