diff --git a/src/node_url.cc b/src/node_url.cc index 30a1a6ec9876ba..149a926841b635 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -95,6 +95,11 @@ void BindingData::DomainToUnicode(const FunctionCallbackInfo& 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.