diff options
author | 2023-03-03 18:45:34 +0800 | |
---|---|---|
committer | 2023-03-03 02:45:34 -0800 | |
commit | 18178b4e48b9b5b96798681a028637ebbd43f6df (patch) | |
tree | 09d8fabe0d26c689ad02bff7efaa8bddc227fa35 | |
parent | 3456831b82c4b95887cd96761e91b5edec95d683 (diff) | |
download | bun-18178b4e48b9b5b96798681a028637ebbd43f6df.tar.gz bun-18178b4e48b9b5b96798681a028637ebbd43f6df.tar.zst bun-18178b4e48b9b5b96798681a028637ebbd43f6df.zip |
Fix http server req url (#2285)
* fix: http url add search query
* fix: add tests
-rw-r--r-- | src/bun.js/http.exports.js | 2 | ||||
-rw-r--r-- | test/bun.js/node-http.test.ts | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/bun.js/http.exports.js b/src/bun.js/http.exports.js index d21f768d4..579991424 100644 --- a/src/bun.js/http.exports.js +++ b/src/bun.js/http.exports.js @@ -348,7 +348,7 @@ export class IncomingMessage extends Readable { this.#bodyStream = null; this.#fakeSocket = undefined; - this.url = url.pathname; + this.url = url.pathname + url.search; assignHeaders(this, req); } diff --git a/test/bun.js/node-http.test.ts b/test/bun.js/node-http.test.ts index 7818fba62..6ba619c3e 100644 --- a/test/bun.js/node-http.test.ts +++ b/test/bun.js/node-http.test.ts @@ -6,12 +6,13 @@ describe("node:http", () => { describe("createServer", async () => { it("hello world", async () => { const server = createServer((req, res) => { + expect(req.url).toBe("/hello?world"); res.writeHead(200, { "Content-Type": "text/plain" }); res.end("Hello World"); }); server.listen(8123); - const res = await fetch("http://localhost:8123"); + const res = await fetch("http://localhost:8123/hello?world"); expect(await res.text()).toBe("Hello World"); server.close(); }); |