From 4a9ae315198d19b8289f764463a5f2379d09dce1 Mon Sep 17 00:00:00 2001 From: Jungku Lee Date: Sun, 20 Aug 2023 18:55:44 +0900 Subject: [PATCH] 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 Reviewed-By: Deokjin Kim --- src/node_url.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/node_url.cc b/src/node_url.cc index 85147ccd1c0d59..60300d08730128 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -100,6 +100,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.