src: add a condition if the argument of DomainToUnicode is empty

PR-URL: https://github.com/nodejs/node/pull/49097
Refs: https://github.com/nodejs/node/pull/46410
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com>
This commit is contained in:
Jungku Lee
2023-08-20 18:55:44 +09:00
committed by GitHub
parent 2557932db2
commit 45e5ec89a6

View File

@@ -100,6 +100,11 @@ void BindingData::DomainToUnicode(const FunctionCallbackInfo<Value>& args) {
CHECK(args[0]->IsString());
std::string input = Utf8Value(env->isolate(), args[0]).ToString();
if (input.empty()) {
return args.GetReturnValue().Set(
String::NewFromUtf8(env->isolate(), "").ToLocalChecked());
}
// It is important to have an initial value that contains a special scheme.
// Since it will change the implementation of `set_hostname` according to URL
// spec.