@@ -131,6 +131,16 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
131
131
132
132
auto result = ada::parse<ada::url_aggregator>(url_string, &base_url.value ());
133
133
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 );
134
144
if (result) {
135
145
url = result.value ();
136
146
} else {
@@ -139,7 +149,6 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
139
149
return ;
140
150
}
141
151
}
142
-
143
152
} else {
144
153
auto result = ada::parse<ada::url_aggregator>(url_string, nullptr );
145
154
if (result) {
@@ -149,7 +158,6 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
149
158
v8::Exception::TypeError (v8::String::Empty (isolate)));
150
159
return ;
151
160
}
152
-
153
161
}
154
162
155
163
auto ret = args.This ();
@@ -162,7 +170,6 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
162
170
urlImpl->BindFinalizer (isolate, ret);
163
171
164
172
args.GetReturnValue ().Set (ret);
165
-
166
173
}
167
174
168
175
@@ -178,7 +185,6 @@ void URLImpl::GetHash(v8::Local<v8::String> property,
178
185
auto value = ptr->GetURL ()->get_hash ();
179
186
info.GetReturnValue ().Set (
180
187
ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
181
-
182
188
}
183
189
184
190
void URLImpl::SetHash (v8::Local<v8::String> property,
@@ -235,7 +241,6 @@ void URLImpl::GetHostName(v8::Local<v8::String> property,
235
241
236
242
info.GetReturnValue ().Set (
237
243
ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
238
-
239
244
}
240
245
241
246
void URLImpl::SetHostName (v8::Local<v8::String> property,
@@ -265,7 +270,6 @@ void URLImpl::GetHref(v8::Local<v8::String> property,
265
270
266
271
info.GetReturnValue ().Set (
267
272
ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
268
-
269
273
}
270
274
271
275
void URLImpl::SetHref (v8::Local<v8::String> property,
@@ -294,7 +298,6 @@ void URLImpl::GetOrigin(v8::Local<v8::String> property,
294
298
295
299
info.GetReturnValue ().Set (
296
300
ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
297
-
298
301
}
299
302
300
303
void URLImpl::GetPassword (v8::Local<v8::String> property,
@@ -310,7 +313,6 @@ void URLImpl::GetPassword(v8::Local<v8::String> property,
310
313
311
314
info.GetReturnValue ().Set (
312
315
ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
313
-
314
316
}
315
317
316
318
void URLImpl::SetPassword (v8::Local<v8::String> property,
@@ -339,7 +341,6 @@ void URLImpl::GetPathName(v8::Local<v8::String> property,
339
341
340
342
info.GetReturnValue ().Set (
341
343
ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
342
-
343
344
}
344
345
345
346
void URLImpl::SetPathName (v8::Local<v8::String> property,
@@ -368,7 +369,6 @@ void URLImpl::GetPort(v8::Local<v8::String> property,
368
369
369
370
info.GetReturnValue ().Set (
370
371
ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
371
-
372
372
}
373
373
374
374
void URLImpl::SetPort (v8::Local<v8::String> property,
@@ -397,7 +397,6 @@ void URLImpl::GetProtocol(v8::Local<v8::String> property,
397
397
398
398
info.GetReturnValue ().Set (
399
399
ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
400
-
401
400
}
402
401
403
402
void URLImpl::SetProtocol (v8::Local<v8::String> property,
@@ -427,7 +426,6 @@ void URLImpl::GetSearch(v8::Local<v8::String> property,
427
426
428
427
info.GetReturnValue ().Set (
429
428
ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
430
-
431
429
}
432
430
433
431
void URLImpl::SetSearch (v8::Local<v8::String> property,
@@ -457,7 +455,6 @@ void URLImpl::GetUserName(v8::Local<v8::String> property,
457
455
458
456
info.GetReturnValue ().Set (
459
457
ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
460
-
461
458
}
462
459
463
460
void URLImpl::SetUserName (v8::Local<v8::String> property,
@@ -474,36 +471,36 @@ void URLImpl::SetUserName(v8::Local<v8::String> property,
474
471
}
475
472
476
473
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 ());
479
476
if (ptr == nullptr ) {
480
- args .GetReturnValue ().SetEmptyString ();
477
+ info .GetReturnValue ().SetEmptyString ();
481
478
return ;
482
479
}
483
- auto isolate = args .GetIsolate ();
480
+ auto isolate = info .GetIsolate ();
484
481
485
482
486
483
auto value = ptr->GetURL ()->get_href ();
487
484
488
485
auto ret = ArgConverter::ConvertToV8String (isolate, value.data (), value.length ());
489
486
490
- args .GetReturnValue ().Set (ret);
487
+ info .GetReturnValue ().Set (ret);
491
488
}
492
489
493
490
494
- void URLImpl::CanParse (const v8::FunctionCallbackInfo<v8::Value> &args ) {
491
+ void URLImpl::CanParse (const v8::FunctionCallbackInfo<v8::Value> &info ) {
495
492
bool value;
496
- auto count = args .Length ();
493
+ auto count = info .Length ();
497
494
498
495
499
496
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>());
502
499
std::string_view base_string_view (base_string.data (), base_string.length ());
503
500
value = can_parse (url_string, &base_string_view);
504
501
} 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 );
506
503
}
507
504
508
- args .GetReturnValue ().Set (value);
505
+ info .GetReturnValue ().Set (value);
509
506
}
0 commit comments