From 63fde1ae3d6d7cbfdbb9b602d789e94f9e464888 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Mon, 8 May 2023 11:36:43 -0400 Subject: [PATCH] url: call `ada::can_parse` directly --- src/node_url.cc | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/node_url.cc b/src/node_url.cc index 078e155fc49374..e37419633e8f13 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -125,32 +125,20 @@ void BindingData::CanParse(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); HandleScope handle_scope(env->isolate()); - Context::Scope context_scope(env->context()); Utf8Value input(env->isolate(), args[0]); - ada::result base; - ada::url_aggregator* base_pointer = nullptr; + std::string_view base; + std::string_view* base_ptr = nullptr; if (args[1]->IsString()) { - base = ada::parse( - Utf8Value(env->isolate(), args[1]).ToString()); - if (!base) { - return args.GetReturnValue().Set(false); - } - base_pointer = &base.value(); + base = Utf8Value(env->isolate(), args[1]).ToStringView(); + base_ptr = &base; } - auto out = - ada::parse(input.ToStringView(), base_pointer); - - args.GetReturnValue().Set(out.has_value()); + args.GetReturnValue().Set(ada::can_parse(input.ToStringView(), base_ptr)); } bool BindingData::FastCanParse(Local receiver, const FastOneByteString& input) { - std::string_view input_view(input.data, input.length); - - auto output = ada::parse(input_view); - - return output.has_value(); + return ada::can_parse(std::string_view(input.data, input.length)); } CFunction BindingData::fast_can_parse_(CFunction::Make(FastCanParse));