From 4784e648503fa99d3fcf0be6ab6684d5843496ff 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
Backport-PR-URL: https://github.com/nodejs/node/pull/48345
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 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,