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 <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Yagiz Nizipli authored and Ulises Gascón committed 2023-09-10 18:09:37 +00:00
1 parent 6ed47bd8fb
commit e787673dcf
2 files changed
+6 -1

No files matched your search

+1 -1
View File
@@ -208,7 +208,7 @@ void BindingData::Format(const FunctionCallbackInfo<Value>& args) {
out->hash = std::nullopt;
}
if (unicode) {
if (unicode && out->has_hostname()) {
out->host = ada::idna::to_unicode(out->get_hostname());
}
+5
View File
@@ -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 })
);