Thanks to visit codestin.com
Credit goes to github.com

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 <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
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β€Ž

Lines changed: 1 addition & 1 deletion
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β€Ž

Lines changed: 5 additions & 0 deletions
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)