Skip to content

Commit f256b16

Browse files
anonrigtargos
authored andcommitted
url: handle unicode hostname if empty
PR-URL: #49396 Fixes: #48759 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 67cb6f9 commit f256b16

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/node_url.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void BindingData::Format(const FunctionCallbackInfo<Value>& args) {
168168
out->hash = std::nullopt;
169169
}
170170

171-
if (unicode) {
171+
if (unicode && out->has_hostname()) {
172172
out->host = ada::idna::to_unicode(out->get_hostname());
173173
}
174174

test/parallel/test-url-format-whatwg.js

+5
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,8 @@ assert.strictEqual(
140140
url.format(new URL('http://user:[email protected]:8080/path'), { unicode: true }),
141141
'http://user:pass@测试.com:8080/path'
142142
);
143+
144+
assert.strictEqual(
145+
url.format(new URL('tel:123')),
146+
url.format(new URL('tel:123'), { unicode: true })
147+
);

0 commit comments

Comments
 (0)