From 243d9c846df5fd9011937655f229b7068b001e3e Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Wed, 17 May 2023 14:51:51 +0900 Subject: fix(ext/node): fix whatwg url formatting (#19146) --- ext/node/polyfills/url.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'ext/node/polyfills') diff --git a/ext/node/polyfills/url.ts b/ext/node/polyfills/url.ts index 4beebe844..28b6060bc 100644 --- a/ext/node/polyfills/url.ts +++ b/ext/node/polyfills/url.ts @@ -939,14 +939,11 @@ export function format( ["Object", "string"], urlObject, ); - } else if (!(urlObject instanceof Url)) { - if (urlObject instanceof URL) { - return formatWhatwg(urlObject, options); - } - return Url.prototype.format.call(urlObject); + } else if (urlObject instanceof URL) { + return formatWhatwg(urlObject, options); } - return (urlObject as Url).format(); + return Url.prototype.format.call(urlObject); } /** @@ -1002,10 +999,9 @@ function formatWhatwg( } ret += "@"; } - // TODO(wafuwfu13): Support unicode option - // ret += options.unicode ? - // domainToUnicode(urlObject.host) : urlObject.host; - ret += urlObject.host; + ret += options.unicode + ? domainToUnicode(urlObject.hostname) + : urlObject.hostname; if (urlObject.port) { ret += `:${urlObject.port}`; } -- cgit v1.2.3