diff --git a/lib/internal/url.js b/lib/internal/url.js index c89296a71f9833..1e8e304d456262 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -1170,9 +1170,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,