aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar zhiyuan <32867472+zhiyuang@users.noreply.github.com> 2023-03-03 18:45:34 +0800
committerGravatar GitHub <noreply@github.com> 2023-03-03 02:45:34 -0800
commit18178b4e48b9b5b96798681a028637ebbd43f6df (patch)
tree09d8fabe0d26c689ad02bff7efaa8bddc227fa35
parent3456831b82c4b95887cd96761e91b5edec95d683 (diff)
downloadbun-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.js2
-rw-r--r--test/bun.js/node-http.test.ts3
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();
});