mirror of
https://github.com/nodejs/node.git
synced 2026-11-27 17:52:27 -05:00
src: modify code for empty string
PR-URL: https://github.com/nodejs/node/pull/49336 Refs: https://github.com/nodejs/node/pull/49097 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Darshan Sen <raisinten@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
This commit is contained in:
1 parent
84195d9584
commit
dc4de1c69b
1 file changed
+4
-6
+4
-6
@@ -78,7 +78,7 @@ void BindingData::DomainToASCII(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
std::string input = Utf8Value(env->isolate(), args[0]).ToString();
|
||||
if (input.empty()) {
|
||||
return args.GetReturnValue().Set(FIXED_ONE_BYTE_STRING(env->isolate(), ""));
|
||||
return args.GetReturnValue().Set(String::Empty(env->isolate()));
|
||||
}
|
||||
|
||||
// It is important to have an initial value that contains a special scheme.
|
||||
@@ -87,7 +87,7 @@ void BindingData::DomainToASCII(const FunctionCallbackInfo<Value>& args) {
|
||||
auto out = ada::parse<ada::url>("ws://x");
|
||||
DCHECK(out);
|
||||
if (!out->set_hostname(input)) {
|
||||
return args.GetReturnValue().Set(FIXED_ONE_BYTE_STRING(env->isolate(), ""));
|
||||
return args.GetReturnValue().Set(String::Empty(env->isolate()));
|
||||
}
|
||||
std::string host = out->get_hostname();
|
||||
args.GetReturnValue().Set(
|
||||
@@ -101,8 +101,7 @@ void BindingData::DomainToUnicode(const FunctionCallbackInfo<Value>& args) {
|
||||
|
||||
std::string input = Utf8Value(env->isolate(), args[0]).ToString();
|
||||
if (input.empty()) {
|
||||
return args.GetReturnValue().Set(
|
||||
String::NewFromUtf8(env->isolate(), "").ToLocalChecked());
|
||||
return args.GetReturnValue().Set(String::Empty(env->isolate()));
|
||||
}
|
||||
|
||||
// It is important to have an initial value that contains a special scheme.
|
||||
@@ -111,8 +110,7 @@ void BindingData::DomainToUnicode(const FunctionCallbackInfo<Value>& args) {
|
||||
auto out = ada::parse<ada::url>("ws://x");
|
||||
DCHECK(out);
|
||||
if (!out->set_hostname(input)) {
|
||||
return args.GetReturnValue().Set(
|
||||
String::NewFromUtf8(env->isolate(), "").ToLocalChecked());
|
||||
return args.GetReturnValue().Set(String::Empty(env->isolate()));
|
||||
}
|
||||
std::string result = ada::unicode::to_unicode(out->get_hostname());
|
||||
|
||||
|
||||
Reference in new issue
Block a user