Skip to content

Commit e787673

Browse files
anonrigUlisesGascon
authored andcommitted
url: handle unicode hostname if empty
PR-URL: #49396 Fixes: #48759 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 6ed47bd commit e787673

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
@@ -208,7 +208,7 @@ void BindingData::Format(const FunctionCallbackInfo<Value>& args) {
208208
out->hash = std::nullopt;
209209
}
210210

211-
if (unicode) {
211+
if (unicode && out->has_hostname()) {
212212
out->host = ada::idna::to_unicode(out->get_hostname());
213213
}
214214

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:pass@xn--0zwm56d.com: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)