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 }) +);