◐ Shell
clean mode source ↗

deps: update ada to 3.1.3 · nodejs/node@f34d78d

1-

/* auto-generated on 2025-02-11 09:47:50 -0500. Do not edit! */

1+

/* auto-generated on 2025-02-26 20:29:12 -0500. Do not edit! */

22

/* begin file src/ada.cpp */

33

#include "ada.h"

44

/* begin file src/checkers.cpp */

@@ -15225,7 +15225,7 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) {

1522515225

namespace ada {

15226152261522715227

tl::expected<url_pattern_init, errors> url_pattern_init::process(

15228-

url_pattern_init init, std::string_view type,

15228+

url_pattern_init init, url_pattern_init::process_type type,

1522915229

std::optional<std::string_view> protocol,

1523015230

std::optional<std::string_view> username,

1523115231

std::optional<std::string_view> password,

@@ -15287,8 +15287,8 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(

1528715287

// If type is not "pattern" and init contains none of "protocol",

1528815288

// "hostname", "port" and "username", then set result["username"] to the

1528915289

// result of processing a base URL string given baseURL’s username and type.

15290-

if (type != "pattern" && !init.protocol && !init.hostname && !init.port &&

15291-

!init.username) {

15290+

if (type != process_type::pattern && !init.protocol && !init.hostname &&

15291+

!init.port && !init.username) {

1529215292

result.username = url_pattern_helpers::process_base_url_string(

1529315293

base_url->get_username(), type);

1529415294

}

@@ -15298,8 +15298,8 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(

1529815298

// "hostname", "port", "username" and "password", then set

1529915299

// result["password"] to the result of processing a base URL string given

1530015300

// baseURL’s password and type.

15301-

if (type != "pattern" && !init.protocol && !init.hostname && !init.port &&

15302-

!init.username && !init.password) {

15301+

if (type != process_type::pattern && !init.protocol && !init.hostname &&

15302+

!init.port && !init.username && !init.password) {

1530315303

result.password = url_pattern_helpers::process_base_url_string(

1530415304

base_url->get_password(), type);

1530515305

}

@@ -15418,6 +15418,8 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(

1541815418

!url_pattern_helpers::is_absolute_pathname(*result.pathname, type)) {

1541915419

// Let baseURLPath be the result of running process a base URL string

1542015420

// given the result of URL path serializing baseURL and type.

15421+

// TODO: Optimization opportunity: Avoid returning a string if no slash

15422+

// exist.

1542115423

std::string base_url_path = url_pattern_helpers::process_base_url_string(

1542215424

base_url->get_pathname(), type);

1542315425

@@ -15430,12 +15432,12 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(

1543015432

if (slash_index != std::string::npos) {

1543115433

// Let new pathname be the code point substring from 0 to slash index +

1543215434

// 1 within baseURLPath.

15433-

std::string new_pathname = base_url_path.substr(0, slash_index + 1);

15435+

base_url_path.resize(slash_index + 1);

1543415436

// Append result["pathname"] to the end of new pathname.

1543515437

ADA_ASSERT_TRUE(result.pathname.has_value());

15436-

new_pathname.append(result.pathname.value());

15438+

base_url_path.append(std::move(*result.pathname));

1543715439

// Set result["pathname"] to new pathname.

15438-

result.pathname = std::move(new_pathname);

15440+

result.pathname = std::move(base_url_path);

1543915441

}

1544015442

}

1544115443

@@ -15473,56 +15475,56 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process(

1547315475

}

15474154761547515477

tl::expected<std::string, errors> url_pattern_init::process_protocol(

15476-

std::string_view value, std::string_view type) {

15478+

std::string_view value, process_type type) {

1547715479

ada_log("process_protocol=", value, " [", type, "]");

1547815480

// Let strippedValue be the given value with a single trailing U+003A (:)

1547915481

// removed, if any.

1548015482

if (value.ends_with(":")) {

1548115483

value.remove_suffix(1);

1548215484

}

1548315485

// If type is "pattern" then return strippedValue.

15484-

if (type == "pattern") {

15486+

if (type == process_type::pattern) {

1548515487

return std::string(value);

1548615488

}

1548715489

// Return the result of running canonicalize a protocol given strippedValue.

1548815490

return url_pattern_helpers::canonicalize_protocol(value);

1548915491

}

15490154921549115493

tl::expected<std::string, errors> url_pattern_init::process_username(

15492-

std::string_view value, std::string_view type) {

15494+

std::string_view value, process_type type) {

1549315495

// If type is "pattern" then return value.

15494-

if (type == "pattern") {

15496+

if (type == process_type::pattern) {

1549515497

return std::string(value);

1549615498

}

1549715499

// Return the result of running canonicalize a username given value.

1549815500

return url_pattern_helpers::canonicalize_username(value);

1549915501

}

15500155021550115503

tl::expected<std::string, errors> url_pattern_init::process_password(

15502-

std::string_view value, std::string_view type) {

15504+

std::string_view value, process_type type) {

1550315505

// If type is "pattern" then return value.

15504-

if (type == "pattern") {

15506+

if (type == process_type::pattern) {

1550515507

return std::string(value);

1550615508

}

1550715509

// Return the result of running canonicalize a password given value.

1550815510

return url_pattern_helpers::canonicalize_password(value);

1550915511

}

15510155121551115513

tl::expected<std::string, errors> url_pattern_init::process_hostname(

15512-

std::string_view value, std::string_view type) {

15514+

std::string_view value, process_type type) {

1551315515

ada_log("process_hostname value=", value, " type=", type);

1551415516

// If type is "pattern" then return value.

15515-

if (type == "pattern") {

15517+

if (type == process_type::pattern) {

1551615518

return std::string(value);

1551715519

}

1551815520

// Return the result of running canonicalize a hostname given value.

1551915521

return url_pattern_helpers::canonicalize_hostname(value);

1552015522

}

15521155231552215524

tl::expected<std::string, errors> url_pattern_init::process_port(

15523-

std::string_view port, std::string_view protocol, std::string_view type) {

15525+

std::string_view port, std::string_view protocol, process_type type) {

1552415526

// If type is "pattern" then return portValue.

15525-

if (type == "pattern") {

15527+

if (type == process_type::pattern) {

1552615528

return std::string(port);

1552715529

}

1552815530

// Return the result of running canonicalize a port given portValue and

@@ -15531,9 +15533,9 @@ tl::expected<std::string, errors> url_pattern_init::process_port(

1553115533

}

15532155341553315535

tl::expected<std::string, errors> url_pattern_init::process_pathname(

15534-

std::string_view value, std::string_view protocol, std::string_view type) {

15536+

std::string_view value, std::string_view protocol, process_type type) {

1553515537

// If type is "pattern" then return pathnameValue.

15536-

if (type == "pattern") {

15538+

if (type == process_type::pattern) {

1553715539

return std::string(value);

1553815540

}

1553915541

@@ -15549,31 +15551,31 @@ tl::expected<std::string, errors> url_pattern_init::process_pathname(

1554915551

}

15550155521555115553

tl::expected<std::string, errors> url_pattern_init::process_search(

15552-

std::string_view value, std::string_view type) {

15554+

std::string_view value, process_type type) {

1555315555

// Let strippedValue be the given value with a single leading U+003F (?)

1555415556

// removed, if any.

1555515557

if (value.starts_with("?")) {

1555615558

value.remove_prefix(1);

1555715559

}

1555815560

ADA_ASSERT_TRUE(!value.starts_with("?"));

1555915561

// If type is "pattern" then return strippedValue.

15560-

if (type == "pattern") {

15562+

if (type == process_type::pattern) {

1556115563

return std::string(value);

1556215564

}

1556315565

// Return the result of running canonicalize a search given strippedValue.

1556415566

return url_pattern_helpers::canonicalize_search(value);

1556515567

}

15566155681556715569

tl::expected<std::string, errors> url_pattern_init::process_hash(

15568-

std::string_view value, std::string_view type) {

15570+

std::string_view value, process_type type) {

1556915571

// Let strippedValue be the given value with a single leading U+0023 (#)

1557015572

// removed, if any.

1557115573

if (value.starts_with("#")) {

1557215574

value.remove_prefix(1);

1557315575

}

1557415576

ADA_ASSERT_TRUE(!value.starts_with("#"));

1557515577

// If type is "pattern" then return strippedValue.

15576-

if (type == "pattern") {

15578+

if (type == process_type::pattern) {

1557715579

return std::string(value);

1557815580

}

1557915581

// Return the result of running canonicalize a hash given strippedValue.

@@ -15599,7 +15601,6 @@ generate_regular_expression_and_name_list(

15599156011560015602

// Let name list be a new list

1560115603

std::vector<std::string> name_list{};

15602-

const std::string full_wildcard_regexp_value = ".*";

15603156041560415605

// For each part of part list:

1560515606

for (const url_pattern_part& part : part_list) {

@@ -15645,7 +15646,7 @@ generate_regular_expression_and_name_list(

1564515646

// Otherwise if part's type is "full-wildcard"

1564615647

else if (part.type == url_pattern_part_type::FULL_WILDCARD) {

1564715648

// then set regexp value to full wildcard regexp value.

15648-

regexp_value = full_wildcard_regexp_value;

15649+

regexp_value = ".*";

1564915650

}

15650156511565115652

// If part's prefix is the empty string and part's suffix is the empty

@@ -15724,7 +15725,7 @@ generate_regular_expression_and_name_list(

1572415725

result += "$";

15725157261572615727

// Return (result, name list)

15727-

return {result, name_list};

15728+

return {std::move(result), std::move(name_list)};

1572815729

}

15729157301573015731

bool is_ipv6_address(std::string_view input) noexcept {

@@ -16387,33 +16388,31 @@ std::string escape_regexp_string(std::string_view input) {

1638716388

}

16388163891638916390

std::string process_base_url_string(std::string_view input,

16390-

std::string_view type) {

16391+

url_pattern_init::process_type type) {

1639116392

// If type is not "pattern" return input.

16392-

if (type != "pattern") {

16393+

if (type != url_pattern_init::process_type::pattern) {

1639316394

return std::string(input);

1639416395

}

1639516396

// Return the result of escaping a pattern string given input.

1639616397

return escape_pattern_string(input);

1639716398

}

163981639916399-

constexpr bool is_absolute_pathname(std::string_view input,

16400-

std::string_view type) noexcept {

16400+

constexpr bool is_absolute_pathname(

16401+

std::string_view input, url_pattern_init::process_type type) noexcept {

1640116402

// If input is the empty string, then return false.

1640216403

if (input.empty()) [[unlikely]] {

1640316404

return false;

1640416405

}

1640516406

// If input[0] is U+002F (/), then return true.

1640616407

if (input.starts_with("/")) return true;

1640716408

// If type is "url", then return false.

16408-

if (type == "url") return false;

16409+

if (type == url_pattern_init::process_type::url) return false;

1640916410

// If input’s code point length is less than 2, then return false.

1641016411

if (input.size() < 2) return false;

1641116412

// If input[0] is U+005C (\) and input[1] is U+002F (/), then return true.

16412-

if (input.starts_with("\\/")) return true;

1641316413

// If input[0] is U+007B ({) and input[1] is U+002F (/), then return true.

16414-

if (input.starts_with("{/")) return true;

1641516414

// Return false.

16416-

return false;

16415+

return input[1] == '/' && (input[0] == '\\' || input[0] == '{');

1641716416

}

16418164171641916418

std::string generate_pattern_string(