@@ -75,20 +75,20 @@ void BindingData::Deserialize(v8::Local<v8::Context> context,
7575
7676void BindingData::DomainToASCII (const FunctionCallbackInfo<Value>& args) {
7777 Environment* env = Environment::GetCurrent (args);
78- CHECK_GE (args.Length (), 1 );
78+ CHECK_GE (args.Length (), 1 ); // input
7979 CHECK (args[0 ]->IsString ());
8080
81- std::string input = Utf8Value (env->isolate (), args[0 ]). ToString ( );
82- if (input.empty ()) {
83- return args.GetReturnValue ().Set ( String::Empty (env-> isolate ()) );
81+ Utf8Value input (env->isolate (), args[0 ]);
82+ if (input.ToStringView (). empty ()) {
83+ return args.GetReturnValue ().SetEmptyString ( );
8484 }
8585
8686 // It is important to have an initial value that contains a special scheme.
8787 // Since it will change the implementation of `set_hostname` according to URL
8888 // spec.
8989 auto out = ada::parse<ada::url>(" ws://x" );
9090 DCHECK (out);
91- if (!out->set_hostname (input)) {
91+ if (!out->set_hostname (input. ToStringView () )) {
9292 return args.GetReturnValue ().Set (String::Empty (env->isolate ()));
9393 }
9494 std::string host = out->get_hostname ();
@@ -98,20 +98,20 @@ void BindingData::DomainToASCII(const FunctionCallbackInfo<Value>& args) {
9898
9999void BindingData::DomainToUnicode (const FunctionCallbackInfo<Value>& args) {
100100 Environment* env = Environment::GetCurrent (args);
101- CHECK_GE (args.Length (), 1 );
101+ CHECK_GE (args.Length (), 1 ); // input
102102 CHECK (args[0 ]->IsString ());
103103
104- std::string input = Utf8Value (env->isolate (), args[0 ]). ToString ( );
105- if (input.empty ()) {
106- return args.GetReturnValue ().Set ( String::Empty (env-> isolate ()) );
104+ Utf8Value input (env->isolate (), args[0 ]);
105+ if (input.ToStringView (). empty ()) {
106+ return args.GetReturnValue ().SetEmptyString ( );
107107 }
108108
109109 // It is important to have an initial value that contains a special scheme.
110110 // Since it will change the implementation of `set_hostname` according to URL
111111 // spec.
112112 auto out = ada::parse<ada::url>(" ws://x" );
113113 DCHECK (out);
114- if (!out->set_hostname (input)) {
114+ if (!out->set_hostname (input. ToStringView () )) {
115115 return args.GetReturnValue ().Set (String::Empty (env->isolate ()));
116116 }
117117 std::string result = ada::unicode::to_unicode (out->get_hostname ());
0 commit comments