@@ -76,20 +76,20 @@ void BindingData::Deserialize(v8::Local<v8::Context> context,
76
76
77
77
void BindingData::DomainToASCII (const FunctionCallbackInfo<Value>& args) {
78
78
Environment* env = Environment::GetCurrent (args);
79
- CHECK_GE (args.Length (), 1 );
79
+ CHECK_GE (args.Length (), 1 ); // input
80
80
CHECK (args[0 ]->IsString ());
81
81
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 ( );
85
85
}
86
86
87
87
// It is important to have an initial value that contains a special scheme.
88
88
// Since it will change the implementation of `set_hostname` according to URL
89
89
// spec.
90
90
auto out = ada::parse<ada::url>(" ws://x" );
91
91
DCHECK (out);
92
- if (!out->set_hostname (input)) {
92
+ if (!out->set_hostname (input. ToStringView () )) {
93
93
return args.GetReturnValue ().Set (String::Empty (env->isolate ()));
94
94
}
95
95
std::string host = out->get_hostname ();
@@ -99,20 +99,20 @@ void BindingData::DomainToASCII(const FunctionCallbackInfo<Value>& args) {
99
99
100
100
void BindingData::DomainToUnicode (const FunctionCallbackInfo<Value>& args) {
101
101
Environment* env = Environment::GetCurrent (args);
102
- CHECK_GE (args.Length (), 1 );
102
+ CHECK_GE (args.Length (), 1 ); // input
103
103
CHECK (args[0 ]->IsString ());
104
104
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 ( );
108
108
}
109
109
110
110
// It is important to have an initial value that contains a special scheme.
111
111
// Since it will change the implementation of `set_hostname` according to URL
112
112
// spec.
113
113
auto out = ada::parse<ada::url>(" ws://x" );
114
114
DCHECK (out);
115
- if (!out->set_hostname (input)) {
115
+ if (!out->set_hostname (input. ToStringView () )) {
116
116
return args.GetReturnValue ().Set (String::Empty (env->isolate ()));
117
117
}
118
118
std::string result = ada::unicode::to_unicode (out->get_hostname ());
0 commit comments