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