7
7
using namespace tns ;
8
8
using namespace ada ;
9
9
10
- URLImpl::URLImpl (url url) : url_(url) {}
10
+ URLImpl::URLImpl (url_aggregator url) : url_(url) {}
11
11
12
12
URLImpl *URLImpl::GetPointer (v8::Local<v8::Object> object) {
13
13
auto ptr = object->GetAlignedPointerFromInternalField (0 );
@@ -17,7 +17,7 @@ URLImpl *URLImpl::GetPointer(v8::Local<v8::Object> object) {
17
17
return static_cast <URLImpl *>(ptr);
18
18
}
19
19
20
- url *URLImpl::GetURL () {
20
+ url_aggregator *URLImpl::GetURL () {
21
21
return &this ->url_ ;
22
22
}
23
23
@@ -86,11 +86,11 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
86
86
auto context = isolate->GetCurrentContext ();
87
87
if (count >= 1 && !value->IsString ()) {
88
88
isolate->ThrowException (
89
- v8::Exception::TypeError (ArgConverter::ConvertToV8String (isolate, " " )));
89
+ v8::Exception::TypeError (v8::String::Empty (isolate)));
90
90
return ;
91
91
}
92
92
93
- url url;
93
+ url_aggregator url;
94
94
95
95
auto url_string = ArgConverter::ConvertToString (args[0 ].As <v8::String>());
96
96
@@ -101,18 +101,18 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
101
101
102
102
if (!can_parse (url_string, &base_string_view)) {
103
103
isolate->ThrowException (
104
- v8::Exception::TypeError (ArgConverter::ConvertToV8String (isolate, " " )));
104
+ v8::Exception::TypeError (v8::String::Empty (isolate)));
105
105
return ;
106
106
}
107
- auto base_url = ada::parse<ada::url >(base_string_view, nullptr );
107
+ auto base_url = ada::parse<ada::url_aggregator >(base_string_view, nullptr );
108
108
109
- auto result = ada::parse<ada::url >(url_string, &base_url.value ());
109
+ auto result = ada::parse<ada::url_aggregator >(url_string, &base_url.value ());
110
110
111
111
if (result) {
112
112
url = result.value ();
113
113
} else {
114
114
isolate->ThrowException (
115
- v8::Exception::TypeError (ArgConverter::ConvertToV8String (isolate, " " )));
115
+ v8::Exception::TypeError (v8::String::Empty (isolate)));
116
116
return ;
117
117
}
118
118
} else if (args[1 ]->IsObject ()) {
@@ -122,31 +122,31 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
122
122
if (!can_parse (std::string_view (url_string.data (), url_string.length ()),
123
123
&base_string_view)) {
124
124
isolate->ThrowException (
125
- v8::Exception::TypeError (ArgConverter::ConvertToV8String (isolate, " " )));
125
+ v8::Exception::TypeError (v8::String::Empty (isolate)));
126
126
return ;
127
127
}
128
128
129
129
130
- auto base_url = ada::parse<ada::url >(base_string_view, nullptr );
130
+ auto base_url = ada::parse<ada::url_aggregator >(base_string_view, nullptr );
131
131
132
- auto result = ada::parse<ada::url >(url_string, &base_url.value ());
132
+ auto result = ada::parse<ada::url_aggregator >(url_string, &base_url.value ());
133
133
134
134
if (result) {
135
135
url = result.value ();
136
136
} else {
137
137
isolate->ThrowException (
138
- v8::Exception::TypeError (ArgConverter::ConvertToV8String (isolate, " " )));
138
+ v8::Exception::TypeError (v8::String::Empty (isolate)));
139
139
return ;
140
140
}
141
141
}
142
142
143
143
} else {
144
- auto result = ada::parse<ada::url >(url_string, nullptr );
144
+ auto result = ada::parse<ada::url_aggregator >(url_string, nullptr );
145
145
if (result) {
146
146
url = result.value ();
147
147
} else {
148
148
isolate->ThrowException (
149
- v8::Exception::TypeError (ArgConverter::ConvertToV8String (isolate, " " )));
149
+ v8::Exception::TypeError (v8::String::Empty (isolate)));
150
150
return ;
151
151
}
152
152
@@ -156,6 +156,7 @@ void URLImpl::Ctor(const v8::FunctionCallbackInfo<v8::Value> &args) {
156
156
157
157
auto urlImpl = new URLImpl (url);
158
158
159
+
159
160
ret->SetAlignedPointerInInternalField (0 , urlImpl);
160
161
161
162
urlImpl->BindFinalizer (isolate, ret);
@@ -174,12 +175,9 @@ void URLImpl::GetHash(v8::Local<v8::String> property,
174
175
}
175
176
auto isolate = info.GetIsolate ();
176
177
177
- auto value = ptr->GetURL ()->hash ;
178
- if (value) {
179
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.value ()));
180
- } else {
181
- info.GetReturnValue ().SetEmptyString ();
182
- }
178
+ auto value = ptr->GetURL ()->get_hash ();
179
+ info.GetReturnValue ().Set (
180
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
183
181
184
182
}
185
183
@@ -206,12 +204,9 @@ void URLImpl::GetHost(v8::Local<v8::String> property,
206
204
}
207
205
auto isolate = info.GetIsolate ();
208
206
209
- auto value = ptr->GetURL ()->host ;
210
- if (value) {
211
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.value ()));
212
- } else {
213
- info.GetReturnValue ().SetEmptyString ();
214
- }
207
+ auto value = ptr->GetURL ()->get_host ();
208
+ info.GetReturnValue ().Set (
209
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
215
210
}
216
211
217
212
void URLImpl::SetHost (v8::Local<v8::String> property,
@@ -238,7 +233,8 @@ void URLImpl::GetHostName(v8::Local<v8::String> property,
238
233
auto isolate = info.GetIsolate ();
239
234
auto value = ptr->GetURL ()->get_hostname ();
240
235
241
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.c_str ()));
236
+ info.GetReturnValue ().Set (
237
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
242
238
243
239
}
244
240
@@ -267,7 +263,8 @@ void URLImpl::GetHref(v8::Local<v8::String> property,
267
263
268
264
auto value = ptr->GetURL ()->get_hostname ();
269
265
270
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.c_str ()));
266
+ info.GetReturnValue ().Set (
267
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
271
268
272
269
}
273
270
@@ -295,7 +292,8 @@ void URLImpl::GetOrigin(v8::Local<v8::String> property,
295
292
296
293
auto value = ptr->GetURL ()->get_origin ();
297
294
298
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.c_str ()));
295
+ info.GetReturnValue ().Set (
296
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
299
297
300
298
}
301
299
@@ -310,7 +308,8 @@ void URLImpl::GetPassword(v8::Local<v8::String> property,
310
308
311
309
auto value = ptr->GetURL ()->get_password ();
312
310
313
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.c_str ()));
311
+ info.GetReturnValue ().Set (
312
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
314
313
315
314
}
316
315
@@ -338,7 +337,8 @@ void URLImpl::GetPathName(v8::Local<v8::String> property,
338
337
339
338
auto value = ptr->GetURL ()->get_pathname ();
340
339
341
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.data ()));
340
+ info.GetReturnValue ().Set (
341
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
342
342
343
343
}
344
344
@@ -366,7 +366,8 @@ void URLImpl::GetPort(v8::Local<v8::String> property,
366
366
367
367
auto value = ptr->GetURL ()->get_port ();
368
368
369
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.c_str ()));
369
+ info.GetReturnValue ().Set (
370
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
370
371
371
372
}
372
373
@@ -394,7 +395,8 @@ void URLImpl::GetProtocol(v8::Local<v8::String> property,
394
395
395
396
auto value = ptr->GetURL ()->get_protocol ();
396
397
397
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.c_str ()));
398
+ info.GetReturnValue ().Set (
399
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
398
400
399
401
}
400
402
@@ -423,7 +425,8 @@ void URLImpl::GetSearch(v8::Local<v8::String> property,
423
425
424
426
auto value = ptr->GetURL ()->get_search ();
425
427
426
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.c_str ()));
428
+ info.GetReturnValue ().Set (
429
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
427
430
428
431
}
429
432
@@ -452,7 +455,8 @@ void URLImpl::GetUserName(v8::Local<v8::String> property,
452
455
453
456
auto value = ptr->GetURL ()->get_username ();
454
457
455
- info.GetReturnValue ().Set (ArgConverter::ConvertToV8String (isolate, value.c_str ()));
458
+ info.GetReturnValue ().Set (
459
+ ArgConverter::ConvertToV8String (isolate, value.data (), value.length ()));
456
460
457
461
}
458
462
@@ -479,9 +483,9 @@ void URLImpl::ToString(const v8::FunctionCallbackInfo<v8::Value> &args) {
479
483
auto isolate = args.GetIsolate ();
480
484
481
485
482
- auto value = ptr->GetURL ()->to_string ();
486
+ auto value = ptr->GetURL ()->get_href ();
483
487
484
- auto ret = ArgConverter::ConvertToV8String (isolate, value.c_str ());
488
+ auto ret = ArgConverter::ConvertToV8String (isolate, value.data (), value. length ());
485
489
486
490
args.GetReturnValue ().Set (ret);
487
491
}
0 commit comments