| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 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! */ | ||
| 2 | 2 | /* begin file src/ada.cpp */ | |
| 3 | 3 | #include "ada.h" | |
| 4 | 4 | /* begin file src/checkers.cpp */ | |
@@ -15225,7 +15225,7 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) { | |||
| 15225 | 15225 | namespace ada { | |
| 15226 | 15226 | ||
| 15227 | 15227 | 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, | ||
| 15229 | 15229 | std::optional<std::string_view> protocol, | |
| 15230 | 15230 | std::optional<std::string_view> username, | |
| 15231 | 15231 | std::optional<std::string_view> password, | |
@@ -15287,8 +15287,8 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process( | |||
| 15287 | 15287 | // If type is not "pattern" and init contains none of "protocol", | |
| 15288 | 15288 | // "hostname", "port" and "username", then set result["username"] to the | |
| 15289 | 15289 | // 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) { | ||
| 15292 | 15292 | result.username = url_pattern_helpers::process_base_url_string( | |
| 15293 | 15293 | base_url->get_username(), type); | |
| 15294 | 15294 | } | |
@@ -15298,8 +15298,8 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process( | |||
| 15298 | 15298 | // "hostname", "port", "username" and "password", then set | |
| 15299 | 15299 | // result["password"] to the result of processing a base URL string given | |
| 15300 | 15300 | // 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) { | ||
| 15303 | 15303 | result.password = url_pattern_helpers::process_base_url_string( | |
| 15304 | 15304 | base_url->get_password(), type); | |
| 15305 | 15305 | } | |
@@ -15418,6 +15418,8 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process( | |||
| 15418 | 15418 | !url_pattern_helpers::is_absolute_pathname(*result.pathname, type)) { | |
| 15419 | 15419 | // Let baseURLPath be the result of running process a base URL string | |
| 15420 | 15420 | // given the result of URL path serializing baseURL and type. | |
| 15421 | + // TODO: Optimization opportunity: Avoid returning a string if no slash | ||
| 15422 | + // exist. | ||
| 15421 | 15423 | std::string base_url_path = url_pattern_helpers::process_base_url_string( | |
| 15422 | 15424 | base_url->get_pathname(), type); | |
| 15423 | 15425 | ||
@@ -15430,12 +15432,12 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process( | |||
| 15430 | 15432 | if (slash_index != std::string::npos) { | |
| 15431 | 15433 | // Let new pathname be the code point substring from 0 to slash index + | |
| 15432 | 15434 | // 1 within baseURLPath. | |
| 15433 | - std::string new_pathname = base_url_path.substr(0, slash_index + 1); | ||
| 15435 | + base_url_path.resize(slash_index + 1); | ||
| 15434 | 15436 | // Append result["pathname"] to the end of new pathname. | |
| 15435 | 15437 | ADA_ASSERT_TRUE(result.pathname.has_value()); | |
| 15436 | - new_pathname.append(result.pathname.value()); | ||
| 15438 | + base_url_path.append(std::move(*result.pathname)); | ||
| 15437 | 15439 | // Set result["pathname"] to new pathname. | |
| 15438 | - result.pathname = std::move(new_pathname); | ||
| 15440 | + result.pathname = std::move(base_url_path); | ||
| 15439 | 15441 | } | |
| 15440 | 15442 | } | |
| 15441 | 15443 | ||
@@ -15473,56 +15475,56 @@ tl::expected<url_pattern_init, errors> url_pattern_init::process( | |||
| 15473 | 15475 | } | |
| 15474 | 15476 | ||
| 15475 | 15477 | 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) { | ||
| 15477 | 15479 | ada_log("process_protocol=", value, " [", type, "]"); | |
| 15478 | 15480 | // Let strippedValue be the given value with a single trailing U+003A (:) | |
| 15479 | 15481 | // removed, if any. | |
| 15480 | 15482 | if (value.ends_with(":")) { | |
| 15481 | 15483 | value.remove_suffix(1); | |
| 15482 | 15484 | } | |
| 15483 | 15485 | // If type is "pattern" then return strippedValue. | |
| 15484 | - if (type == "pattern") { | ||
| 15486 | + if (type == process_type::pattern) { | ||
| 15485 | 15487 | return std::string(value); | |
| 15486 | 15488 | } | |
| 15487 | 15489 | // Return the result of running canonicalize a protocol given strippedValue. | |
| 15488 | 15490 | return url_pattern_helpers::canonicalize_protocol(value); | |
| 15489 | 15491 | } | |
| 15490 | 15492 | ||
| 15491 | 15493 | 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) { | ||
| 15493 | 15495 | // If type is "pattern" then return value. | |
| 15494 | - if (type == "pattern") { | ||
| 15496 | + if (type == process_type::pattern) { | ||
| 15495 | 15497 | return std::string(value); | |
| 15496 | 15498 | } | |
| 15497 | 15499 | // Return the result of running canonicalize a username given value. | |
| 15498 | 15500 | return url_pattern_helpers::canonicalize_username(value); | |
| 15499 | 15501 | } | |
| 15500 | 15502 | ||
| 15501 | 15503 | 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) { | ||
| 15503 | 15505 | // If type is "pattern" then return value. | |
| 15504 | - if (type == "pattern") { | ||
| 15506 | + if (type == process_type::pattern) { | ||
| 15505 | 15507 | return std::string(value); | |
| 15506 | 15508 | } | |
| 15507 | 15509 | // Return the result of running canonicalize a password given value. | |
| 15508 | 15510 | return url_pattern_helpers::canonicalize_password(value); | |
| 15509 | 15511 | } | |
| 15510 | 15512 | ||
| 15511 | 15513 | 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) { | ||
| 15513 | 15515 | ada_log("process_hostname value=", value, " type=", type); | |
| 15514 | 15516 | // If type is "pattern" then return value. | |
| 15515 | - if (type == "pattern") { | ||
| 15517 | + if (type == process_type::pattern) { | ||
| 15516 | 15518 | return std::string(value); | |
| 15517 | 15519 | } | |
| 15518 | 15520 | // Return the result of running canonicalize a hostname given value. | |
| 15519 | 15521 | return url_pattern_helpers::canonicalize_hostname(value); | |
| 15520 | 15522 | } | |
| 15521 | 15523 | ||
| 15522 | 15524 | 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) { | ||
| 15524 | 15526 | // If type is "pattern" then return portValue. | |
| 15525 | - if (type == "pattern") { | ||
| 15527 | + if (type == process_type::pattern) { | ||
| 15526 | 15528 | return std::string(port); | |
| 15527 | 15529 | } | |
| 15528 | 15530 | // 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( | |||
| 15531 | 15533 | } | |
| 15532 | 15534 | ||
| 15533 | 15535 | 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) { | ||
| 15535 | 15537 | // If type is "pattern" then return pathnameValue. | |
| 15536 | - if (type == "pattern") { | ||
| 15538 | + if (type == process_type::pattern) { | ||
| 15537 | 15539 | return std::string(value); | |
| 15538 | 15540 | } | |
| 15539 | 15541 | ||
@@ -15549,31 +15551,31 @@ tl::expected<std::string, errors> url_pattern_init::process_pathname( | |||
| 15549 | 15551 | } | |
| 15550 | 15552 | ||
| 15551 | 15553 | 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) { | ||
| 15553 | 15555 | // Let strippedValue be the given value with a single leading U+003F (?) | |
| 15554 | 15556 | // removed, if any. | |
| 15555 | 15557 | if (value.starts_with("?")) { | |
| 15556 | 15558 | value.remove_prefix(1); | |
| 15557 | 15559 | } | |
| 15558 | 15560 | ADA_ASSERT_TRUE(!value.starts_with("?")); | |
| 15559 | 15561 | // If type is "pattern" then return strippedValue. | |
| 15560 | - if (type == "pattern") { | ||
| 15562 | + if (type == process_type::pattern) { | ||
| 15561 | 15563 | return std::string(value); | |
| 15562 | 15564 | } | |
| 15563 | 15565 | // Return the result of running canonicalize a search given strippedValue. | |
| 15564 | 15566 | return url_pattern_helpers::canonicalize_search(value); | |
| 15565 | 15567 | } | |
| 15566 | 15568 | ||
| 15567 | 15569 | 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) { | ||
| 15569 | 15571 | // Let strippedValue be the given value with a single leading U+0023 (#) | |
| 15570 | 15572 | // removed, if any. | |
| 15571 | 15573 | if (value.starts_with("#")) { | |
| 15572 | 15574 | value.remove_prefix(1); | |
| 15573 | 15575 | } | |
| 15574 | 15576 | ADA_ASSERT_TRUE(!value.starts_with("#")); | |
| 15575 | 15577 | // If type is "pattern" then return strippedValue. | |
| 15576 | - if (type == "pattern") { | ||
| 15578 | + if (type == process_type::pattern) { | ||
| 15577 | 15579 | return std::string(value); | |
| 15578 | 15580 | } | |
| 15579 | 15581 | // Return the result of running canonicalize a hash given strippedValue. | |
@@ -15599,7 +15601,6 @@ generate_regular_expression_and_name_list( | |||
| 15599 | 15601 | ||
| 15600 | 15602 | // Let name list be a new list | |
| 15601 | 15603 | std::vector<std::string> name_list{}; | |
| 15602 | - const std::string full_wildcard_regexp_value = ".*"; | ||
| 15603 | 15604 | ||
| 15604 | 15605 | // For each part of part list: | |
| 15605 | 15606 | for (const url_pattern_part& part : part_list) { | |
@@ -15645,7 +15646,7 @@ generate_regular_expression_and_name_list( | |||
| 15645 | 15646 | // Otherwise if part's type is "full-wildcard" | |
| 15646 | 15647 | else if (part.type == url_pattern_part_type::FULL_WILDCARD) { | |
| 15647 | 15648 | // then set regexp value to full wildcard regexp value. | |
| 15648 | - regexp_value = full_wildcard_regexp_value; | ||
| 15649 | + regexp_value = ".*"; | ||
| 15649 | 15650 | } | |
| 15650 | 15651 | ||
| 15651 | 15652 | // 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( | |||
| 15724 | 15725 | result += "$"; | |
| 15725 | 15726 | ||
| 15726 | 15727 | // Return (result, name list) | |
| 15727 | - return {result, name_list}; | ||
| 15728 | + return {std::move(result), std::move(name_list)}; | ||
| 15728 | 15729 | } | |
| 15729 | 15730 | ||
| 15730 | 15731 | bool is_ipv6_address(std::string_view input) noexcept { | |
@@ -16387,33 +16388,31 @@ std::string escape_regexp_string(std::string_view input) { | |||
| 16387 | 16388 | } | |
| 16388 | 16389 | ||
| 16389 | 16390 | std::string process_base_url_string(std::string_view input, | |
| 16390 | - std::string_view type) { | ||
| 16391 | + url_pattern_init::process_type type) { | ||
| 16391 | 16392 | // If type is not "pattern" return input. | |
| 16392 | - if (type != "pattern") { | ||
| 16393 | + if (type != url_pattern_init::process_type::pattern) { | ||
| 16393 | 16394 | return std::string(input); | |
| 16394 | 16395 | } | |
| 16395 | 16396 | // Return the result of escaping a pattern string given input. | |
| 16396 | 16397 | return escape_pattern_string(input); | |
| 16397 | 16398 | } | |
| 16398 | 16399 | ||
| 16399 | - 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 { | ||
| 16401 | 16402 | // If input is the empty string, then return false. | |
| 16402 | 16403 | if (input.empty()) [[unlikely]] { | |
| 16403 | 16404 | return false; | |
| 16404 | 16405 | } | |
| 16405 | 16406 | // If input[0] is U+002F (/), then return true. | |
| 16406 | 16407 | if (input.starts_with("/")) return true; | |
| 16407 | 16408 | // If type is "url", then return false. | |
| 16408 | - if (type == "url") return false; | ||
| 16409 | + if (type == url_pattern_init::process_type::url) return false; | ||
| 16409 | 16410 | // If input’s code point length is less than 2, then return false. | |
| 16410 | 16411 | if (input.size() < 2) return false; | |
| 16411 | 16412 | // If input[0] is U+005C (\) and input[1] is U+002F (/), then return true. | |
| 16412 | - if (input.starts_with("\\/")) return true; | ||
| 16413 | 16413 | // If input[0] is U+007B ({) and input[1] is U+002F (/), then return true. | |
| 16414 | - if (input.starts_with("{/")) return true; | ||
| 16415 | 16414 | // Return false. | |
| 16416 | - return false; | ||
| 16415 | + return input[1] == '/' && (input[0] == '\\' || input[0] == '{'); | ||
| 16417 | 16416 | } | |
| 16418 | 16417 | ||
| 16419 | 16418 | std::string generate_pattern_string( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments