From ccd73d6d3fd2dfffbcc0106773318bcc94249b5b Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Sun, 19 Mar 2023 04:25:35 +0100 Subject: [PATCH] url: allow extension of user provided URL objects PR-URL: https://github.com/nodejs/node/pull/46989 Fixes: https://github.com/nodejs/node/issues/46981 Reviewed-By: Yagiz Nizipli --- lib/internal/url.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/internal/url.js b/lib/internal/url.js index 4296b9929802cc..c8af62b288b42a 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1171,9 +1171,9 @@ function urlToHttpOptions(url) { __proto__: null, ...url, // In case the url object was extended by the user. protocol: url.protocol, - hostname: url.hostname && StringPrototypeStartsWith(url.hostname, '[') ? - StringPrototypeSlice(url.hostname, 1, -1) : - url.hostname, + hostname: hostname && StringPrototypeStartsWith(hostname, '[') ? + StringPrototypeSlice(hostname, 1, -1) : + hostname, hash: url.hash, search: search, pathname: pathname,