@@ -76,20 +76,20 @@ void BindingData::Deserialize(v8::Local<v8::Context> context,
7676
7777void BindingData::DomainToASCII (const FunctionCallbackInfo<Value>& args) {
7878 Environment* env = Environment::GetCurrent (args);
79- CHECK_GE (args.Length (), 1 );
79+ CHECK_GE (args.Length (), 1 ); // input
8080 CHECK (args[0 ]->IsString ());
8181
82- std::string input = Utf8Value (env->isolate (), args[0 ]). ToString ( );
83- if (input.empty ()) {
84- return args.GetReturnValue ().Set ( String::Empty (env-> isolate ()) );
82+ Utf8Value input (env->isolate (), args[0 ]);
83+ if (input.ToStringView (). empty ()) {
84+ return args.GetReturnValue ().SetEmptyString ( );
8585 }
8686
8787 // It is important to have an initial value that contains a special scheme.
8888 // Since it will change the implementation of `set_hostname` according to URL
8989 // spec.
9090 auto out = ada::parse<ada::url>(" ws://x" );
9191 DCHECK (out);
92- if (!out->set_hostname (input)) {
92+ if (!out->set_hostname (input. ToStringView () )) {
9393 return args.GetReturnValue ().Set (String::Empty (env->isolate ()));
9494 }
9595 std::string host = out->get_hostname ();
@@ -99,20 +99,20 @@ void BindingData::DomainToASCII(const FunctionCallbackInfo<Value>& args) {
9999
100100void BindingData::DomainToUnicode (const FunctionCallbackInfo<Value>& args) {
101101 Environment* env = Environment::GetCurrent (args);
102- CHECK_GE (args.Length (), 1 );
102+ CHECK_GE (args.Length (), 1 ); // input
103103 CHECK (args[0 ]->IsString ());
104104
105- std::string input = Utf8Value (env->isolate (), args[0 ]). ToString ( );
106- if (input.empty ()) {
107- return args.GetReturnValue ().Set ( String::Empty (env-> isolate ()) );
105+ Utf8Value input (env->isolate (), args[0 ]);
106+ if (input.ToStringView (). empty ()) {
107+ return args.GetReturnValue ().SetEmptyString ( );
108108 }
109109
110110 // It is important to have an initial value that contains a special scheme.
111111 // Since it will change the implementation of `set_hostname` according to URL
112112 // spec.
113113 auto out = ada::parse<ada::url>(" ws://x" );
114114 DCHECK (out);
115- if (!out->set_hostname (input)) {
115+ if (!out->set_hostname (input. ToStringView () )) {
116116 return args.GetReturnValue ().Set (String::Empty (env->isolate ()));
117117 }
118118 std::string result = ada::unicode::to_unicode (out->get_hostname ());
0 commit comments