diff --git a/ext/node/ops/http.rs b/ext/node/ops/http.rs index 0fd088d235..03bda960ee 100644 --- a/ext/node/ops/http.rs +++ b/ext/node/ops/http.rs @@ -167,9 +167,11 @@ where let mut request = http::Request::new(body); *request.method_mut() = method.clone(); - *request.uri_mut() = url_parsed - .path() - .to_string() + let path = url_parsed.path(); + let query = url_parsed.query(); + *request.uri_mut() = query + .map(|q| format!("{}?{}", path, q)) + .unwrap_or_else(|| path.to_string()) .parse() .map_err(|_| type_error("Invalid URL"))?; *request.headers_mut() = header_map; diff --git a/tests/unit_node/http_test.ts b/tests/unit_node/http_test.ts index ee52d431c0..cd4e319cb7 100644 --- a/tests/unit_node/http_test.ts +++ b/tests/unit_node/http_test.ts @@ -794,14 +794,13 @@ Deno.test("[node/http] ClientRequest PUT", async () => { assertEquals(body, "hello world"); }); -Deno.test("[node/http] ClientRequest search params", { - ignore: true, -}, async () => { +Deno.test("[node/http] ClientRequest search params", async () => { let body = ""; const { promise, resolve, reject } = Promise.withResolvers(); const req = http.request({ - host: "localhost:4545", - path: "search_params?foo=bar", + host: "localhost", + port: 4545, + path: "/search_params?foo=bar", }, (resp) => { resp.on("data", (chunk) => { body += chunk;