From 08614b612592221306b90c747ce3e3f9d0f7eee0 Mon Sep 17 00:00:00 2001 From: Martin DONADIEU Date: Tue, 18 Nov 2025 23:02:17 +0000 Subject: [PATCH 1/6] Replace url.parse with URL constructor --- lib/node/NodeHttpStack.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/node/NodeHttpStack.ts b/lib/node/NodeHttpStack.ts index e1334d79..15537fca 100644 --- a/lib/node/NodeHttpStack.ts +++ b/lib/node/NodeHttpStack.ts @@ -3,7 +3,6 @@ import * as http from 'node:http' import * as https from 'node:https' import { Readable, Transform, type Writable } from 'node:stream' -import { parse } from 'node:url' import isStream from 'is-stream' import throttle from 'lodash.throttle' import type { @@ -92,7 +91,7 @@ class Request implements HttpRequest { return new Promise((resolve, reject) => { const options = { - ...parse(this._url), + ...(new URL((this._url)), ...this._requestOptions, method: this._method, From 490e79569b37934ad0f98a2de07ff9919e5d863c Mon Sep 17 00:00:00 2001 From: Martin DONADIEU Date: Tue, 18 Nov 2025 23:03:05 +0000 Subject: [PATCH 2/6] Remove outdated comments in NodeHttpStack.ts Removed outdated comments regarding url.parse method. --- lib/node/NodeHttpStack.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/node/NodeHttpStack.ts b/lib/node/NodeHttpStack.ts index 15537fca..780ec9fe 100644 --- a/lib/node/NodeHttpStack.ts +++ b/lib/node/NodeHttpStack.ts @@ -1,5 +1,3 @@ -// The url.parse method is superseeded by the url.URL constructor, -// but it is still included in Node.js import * as http from 'node:http' import * as https from 'node:https' import { Readable, Transform, type Writable } from 'node:stream' From 9bda268a258429584f80a0dcfc3b57ee5642db76 Mon Sep 17 00:00:00 2001 From: Martin Donadieu Date: Tue, 18 Nov 2025 23:07:38 +0000 Subject: [PATCH 3/6] Fix URL construction in Request class --- lib/node/NodeHttpStack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node/NodeHttpStack.ts b/lib/node/NodeHttpStack.ts index 780ec9fe..3a49b277 100644 --- a/lib/node/NodeHttpStack.ts +++ b/lib/node/NodeHttpStack.ts @@ -89,7 +89,7 @@ class Request implements HttpRequest { return new Promise((resolve, reject) => { const options = { - ...(new URL((this._url)), + ...(new URL(this._url)), ...this._requestOptions, method: this._method, From 0874d457a16d2edafa871a78e281646841475d01 Mon Sep 17 00:00:00 2001 From: Martin Donadieu Date: Tue, 18 Nov 2025 23:08:59 +0000 Subject: [PATCH 4/6] Fix spread operator usage in Request class URL options --- lib/node/NodeHttpStack.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node/NodeHttpStack.ts b/lib/node/NodeHttpStack.ts index 3a49b277..6785187f 100644 --- a/lib/node/NodeHttpStack.ts +++ b/lib/node/NodeHttpStack.ts @@ -89,7 +89,7 @@ class Request implements HttpRequest { return new Promise((resolve, reject) => { const options = { - ...(new URL(this._url)), + ...new URL(this._url), ...this._requestOptions, method: this._method, From a8337f0a41902603f568a5aaff083fa8dd16e719 Mon Sep 17 00:00:00 2001 From: Martin Donadieu Date: Tue, 18 Nov 2025 23:13:31 +0000 Subject: [PATCH 5/6] Refactor URL handling in Request class to use URL constructor for better clarity --- lib/node/NodeHttpStack.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/node/NodeHttpStack.ts b/lib/node/NodeHttpStack.ts index 6785187f..f3b9ac7e 100644 --- a/lib/node/NodeHttpStack.ts +++ b/lib/node/NodeHttpStack.ts @@ -88,8 +88,12 @@ class Request implements HttpRequest { } return new Promise((resolve, reject) => { + const parsedUrl = new URL(this._url) const options = { - ...new URL(this._url), + protocol: parsedUrl.protocol, + hostname: parsedUrl.hostname, + port: parsedUrl.port, + path: parsedUrl.pathname + parsedUrl.search, ...this._requestOptions, method: this._method, From 4143a9be0b8396d5aca83f66a2a9997d515291ed Mon Sep 17 00:00:00 2001 From: Martin Donadieu Date: Mon, 24 Nov 2025 00:33:41 +0000 Subject: [PATCH 6/6] Refactor Request class to simplify URL handling in send method --- lib/node/NodeHttpStack.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/lib/node/NodeHttpStack.ts b/lib/node/NodeHttpStack.ts index f3b9ac7e..cd60025b 100644 --- a/lib/node/NodeHttpStack.ts +++ b/lib/node/NodeHttpStack.ts @@ -88,12 +88,8 @@ class Request implements HttpRequest { } return new Promise((resolve, reject) => { - const parsedUrl = new URL(this._url) + const url = new URL(this._url) const options = { - protocol: parsedUrl.protocol, - hostname: parsedUrl.hostname, - port: parsedUrl.port, - path: parsedUrl.pathname + parsedUrl.search, ...this._requestOptions, method: this._method, @@ -110,8 +106,8 @@ class Request implements HttpRequest { options.headers['Content-Length'] = body.size } - const httpModule = options.protocol === 'https:' ? https : http - this._request = httpModule.request(options) + const httpModule = url.protocol === 'https:' ? https : http + this._request = httpModule.request(url, options) const req = this._request req.on('response', (res) => { const resChunks: Buffer[] = []