@@ -131,6 +131,16 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
131131
132132 auto result = ada::parse<ada::url_aggregator>(url_string, &base_url.value ());
133133
134+ if (result) {
135+ url = result.value ();
136+ } else {
137+ isolate->ThrowException (
138+ v8::Exception::TypeError (v8::String::Empty (isolate)));
139+ return ;
140+ }
141+ } else {
142+ // treat 2nd arg as undefined otherwise.
143+ auto result = ada::parse<ada::url_aggregator>(url_string, nullptr );
134144 if (result) {
135145 url = result.value ();
136146 } else {
@@ -139,7 +149,6 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
139149 return ;
140150 }
141151 }
142-
143152 } else {
144153 auto result = ada::parse<ada::url_aggregator>(url_string, nullptr );
145154 if (result) {
@@ -149,7 +158,6 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
149158 v8::Exception::TypeError (v8::String::Empty (isolate)));
150159 return ;
151160 }
152-
153161 }
154162
155163 auto ret = args.This ();
@@ -162,7 +170,6 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
162170 urlImpl->BindFinalizer (isolate, ret);
163171
164172 args.GetReturnValue ().Set (ret);
165-
166173}
167174
168175
@@ -178,7 +185,6 @@ void URLImpl::GetHash(v8::Local<v8::String> property,
178185 auto value = ptr->GetURL ()->get_hash ();
179186 info.GetReturnValue ().Set (
180187 ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
181-
182188}
183189
184190void URLImpl::SetHash (v8::Local<v8::String> property,
@@ -235,7 +241,6 @@ void URLImpl::GetHostName(v8::Local<v8::String> property,
235241
236242 info.GetReturnValue ().Set (
237243 ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
238-
239244}
240245
241246void URLImpl::SetHostName (v8::Local<v8::String> property,
@@ -265,7 +270,6 @@ void URLImpl::GetHref(v8::Local<v8::String> property,
265270
266271 info.GetReturnValue ().Set (
267272 ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
268-
269273}
270274
271275void URLImpl::SetHref (v8::Local<v8::String> property,
@@ -294,7 +298,6 @@ void URLImpl::GetOrigin(v8::Local<v8::String> property,
294298
295299 info.GetReturnValue ().Set (
296300 ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
297-
298301}
299302
300303void URLImpl::GetPassword (v8::Local<v8::String> property,
@@ -310,7 +313,6 @@ void URLImpl::GetPassword(v8::Local<v8::String> property,
310313
311314 info.GetReturnValue ().Set (
312315 ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
313-
314316}
315317
316318void URLImpl::SetPassword (v8::Local<v8::String> property,
@@ -339,7 +341,6 @@ void URLImpl::GetPathName(v8::Local<v8::String> property,
339341
340342 info.GetReturnValue ().Set (
341343 ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
342-
343344}
344345
345346void URLImpl::SetPathName (v8::Local<v8::String> property,
@@ -368,7 +369,6 @@ void URLImpl::GetPort(v8::Local<v8::String> property,
368369
369370 info.GetReturnValue ().Set (
370371 ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
371-
372372}
373373
374374void URLImpl::SetPort (v8::Local<v8::String> property,
@@ -397,7 +397,6 @@ void URLImpl::GetProtocol(v8::Local<v8::String> property,
397397
398398 info.GetReturnValue ().Set (
399399 ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
400-
401400}
402401
403402void URLImpl::SetProtocol (v8::Local<v8::String> property,
@@ -427,7 +426,6 @@ void URLImpl::GetSearch(v8::Local<v8::String> property,
427426
428427 info.GetReturnValue ().Set (
429428 ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
430-
431429}
432430
433431void URLImpl::SetSearch (v8::Local<v8::String> property,
@@ -457,7 +455,6 @@ void URLImpl::GetUserName(v8::Local<v8::String> property,
457455
458456 info.GetReturnValue ().Set (
459457 ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
460-
461458}
462459
463460void URLImpl::SetUserName (v8::Local<v8::String> property,
@@ -474,36 +471,36 @@ void URLImpl::SetUserName(v8::Local<v8::String> property,
474471}
475472
476473
477- void URLImpl::ToString (const v8::FunctionCallbackInfo<v8::Value> &args ) {
478- URLImpl *ptr = GetPointer (args .This ());
474+ void URLImpl::ToString (const v8::FunctionCallbackInfo<v8::Value> &info ) {
475+ URLImpl *ptr = GetPointer (info .This ());
479476 if (ptr == nullptr ) {
480- args .GetReturnValue ().SetEmptyString ();
477+ info .GetReturnValue ().SetEmptyString ();
481478 return ;
482479 }
483- auto isolate = args .GetIsolate ();
480+ auto isolate = info .GetIsolate ();
484481
485482
486483 auto value = ptr->GetURL ()->get_href ();
487484
488485 auto ret = ArgConverter::ConvertToV8String (isolate, value.data (), value.length ());
489486
490- args .GetReturnValue ().Set (ret);
487+ info .GetReturnValue ().Set (ret);
491488}
492489
493490
494- void URLImpl::CanParse (const v8::FunctionCallbackInfo<v8::Value> &args ) {
491+ void URLImpl::CanParse (const v8::FunctionCallbackInfo<v8::Value> &info ) {
495492 bool value;
496- auto count = args .Length ();
493+ auto count = info .Length ();
497494
498495
499496 if (count > 1 ) {
500- auto url_string = ArgConverter::ConvertToString (args [0 ].As <v8::String>());
501- auto base_string = ArgConverter::ConvertToString (args [1 ].As <v8::String>());
497+ auto url_string = ArgConverter::ConvertToString (info [0 ].As <v8::String>());
498+ auto base_string = ArgConverter::ConvertToString (info [1 ].As <v8::String>());
502499 std::string_view base_string_view (base_string.data (), base_string.length ());
503500 value = can_parse (url_string, &base_string_view);
504501 } else {
505- value = can_parse (ArgConverter::ConvertToString (args [0 ].As <v8::String>()).c_str (), nullptr );
502+ value = can_parse (ArgConverter::ConvertToString (info [0 ].As <v8::String>()).c_str (), nullptr );
506503 }
507504
508- args .GetReturnValue ().Set (value);
505+ info .GetReturnValue ().Set (value);
509506}
0 commit comments