From ae94700636bd247bfd48e0c4ef22a0a49e1bca13 Mon Sep 17 00:00:00 2001 From: Sergey Chernyshev Date: Thu, 25 Apr 2024 04:21:17 +0200 Subject: [PATCH] url: handle unicode hostname if empty PR-URL: https://github.com/nodejs/node/pull/49396 Fixes: https://github.com/nodejs/node/issues/48759 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- graal-nodejs/src/node_url.cc | 2 +- graal-nodejs/test/parallel/test-url-format-whatwg.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/graal-nodejs/src/node_url.cc b/graal-nodejs/src/node_url.cc index 149a926841b..4d3c8108fa6 100644 --- a/graal-nodejs/src/node_url.cc +++ b/graal-nodejs/src/node_url.cc @@ -168,7 +168,7 @@ void BindingData::Format(const FunctionCallbackInfo& args) { out->hash = std::nullopt; } - if (unicode) { + if (unicode && out->has_hostname()) { out->host = ada::idna::to_unicode(out->get_hostname()); } diff --git a/graal-nodejs/test/parallel/test-url-format-whatwg.js b/graal-nodejs/test/parallel/test-url-format-whatwg.js index d1f0e0bcbdd..bf9f8eaac63 100644 --- a/graal-nodejs/test/parallel/test-url-format-whatwg.js +++ b/graal-nodejs/test/parallel/test-url-format-whatwg.js @@ -140,3 +140,8 @@ assert.strictEqual( url.format(new URL('http://user:pass@xn--0zwm56d.com:8080/path'), { unicode: true }), 'http://user:pass@测试.com:8080/path' ); + +assert.strictEqual( + url.format(new URL('tel:123')), + url.format(new URL('tel:123'), { unicode: true }) +);