10
10
#include " path.h"
11
11
#include " util-inl.h"
12
12
#include " v8-fast-api-calls.h"
13
+ #include " v8-local-handle.h"
13
14
#include " v8.h"
14
15
15
16
#include < cstdint>
@@ -21,7 +22,7 @@ namespace url {
21
22
22
23
using v8::CFunction;
23
24
using v8::Context;
24
- using v8::FastOneByteString ;
25
+ using v8::FastApiCallbackOptions ;
25
26
using v8::FunctionCallbackInfo;
26
27
using v8::HandleScope;
27
28
using v8::Isolate;
@@ -282,18 +283,45 @@ void BindingData::CanParse(const FunctionCallbackInfo<Value>& args) {
282
283
args.GetReturnValue ().Set (can_parse);
283
284
}
284
285
285
- bool BindingData::FastCanParse (Local<Value> receiver,
286
- const FastOneByteString& input) {
286
+ bool BindingData::FastCanParse (
287
+ Local<Value> receiver,
288
+ Local<Value> input,
289
+ // NOLINTNEXTLINE(runtime/references) This is V8 api.
290
+ FastApiCallbackOptions& options) {
287
291
TRACK_V8_FAST_API_CALL (" url.canParse" );
288
- return ada::can_parse (std::string_view (input.data , input.length ));
292
+ auto isolate = options.isolate ;
293
+ HandleScope handleScope (isolate);
294
+ Local<String> str;
295
+ if (!input->ToString (isolate->GetCurrentContext ()).ToLocal (&str)) {
296
+ return false ;
297
+ }
298
+ Utf8Value utf8 (isolate, str);
299
+ return ada::can_parse (utf8.ToStringView ());
289
300
}
290
301
291
- bool BindingData::FastCanParseWithBase (Local<Value> receiver,
292
- const FastOneByteString& input,
293
- const FastOneByteString& base) {
302
+ bool BindingData::FastCanParseWithBase (
303
+ Local<Value> receiver,
304
+ Local<Value> input,
305
+ Local<Value> base,
306
+ // NOLINTNEXTLINE(runtime/references) This is V8 api.
307
+ FastApiCallbackOptions& options) {
294
308
TRACK_V8_FAST_API_CALL (" url.canParse.withBase" );
295
- auto base_view = std::string_view (base.data , base.length );
296
- return ada::can_parse (std::string_view (input.data , input.length ), &base_view);
309
+ auto isolate = options.isolate ;
310
+ HandleScope handleScope (isolate);
311
+ auto context = isolate->GetCurrentContext ();
312
+ Local<String> input_str;
313
+ if (!input->ToString (context).ToLocal (&input_str)) {
314
+ return false ;
315
+ }
316
+ Local<String> base_str;
317
+ if (!base->ToString (context).ToLocal (&base_str)) {
318
+ return false ;
319
+ }
320
+ Utf8Value input_utf8 (isolate, input_str);
321
+ Utf8Value base_utf8 (isolate, base_str);
322
+
323
+ auto base_view = base_utf8.ToStringView ();
324
+ return ada::can_parse (input_utf8.ToStringView (), &base_view);
297
325
}
298
326
299
327
CFunction BindingData::fast_can_parse_methods_[] = {
0 commit comments