diff --git a/Cargo.lock b/Cargo.lock index 37b368b..881ef64 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 4 [[package]] name = "ada-url" -version = "3.2.3" +version = "3.2.4" dependencies = [ "cc", "criterion", @@ -595,9 +595,9 @@ checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" [[package]] name = "syn" -version = "2.0.100" +version = "2.0.101" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0" +checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" dependencies = [ "proc-macro2", "quote", diff --git a/Cargo.toml b/Cargo.toml index 587c4d0..691a231 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ authors = [ "LongYinan ", "Boshen " ] -version = "3.2.3" +version = "3.2.4" edition = "2024" description = "Fast WHATWG Compliant URL parser" documentation = "https://docs.rs/ada-url" diff --git a/build.rs b/build.rs index 8125686..93769be 100644 --- a/build.rs +++ b/build.rs @@ -116,7 +116,8 @@ fn main() { .file("./deps/ada.cpp") .include("./deps") .cpp(true) - .std("c++20"); + .std("c++20") + .define("ADA_INCLUDE_URL_PATTERN", "0"); let compile_target_arch = env::var("CARGO_CFG_TARGET_ARCH").expect("CARGO_CFG_TARGET_ARCH"); let compile_target_os = env::var("CARGO_CFG_TARGET_OS").expect("CARGO_CFG_TARGET_OS"); diff --git a/deps/ada.cpp b/deps/ada.cpp index f670459..d4f228e 100644 --- a/deps/ada.cpp +++ b/deps/ada.cpp @@ -1,4 +1,4 @@ -/* auto-generated on 2025-04-24 20:04:09 -0400. Do not edit! */ +/* auto-generated on 2025-04-28 12:16:36 -0400. Do not edit! */ /* begin file src/ada.cpp */ #include "ada.h" /* begin file src/checkers.cpp */ @@ -56,8 +56,8 @@ ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept { } // We have 0x followed by some characters, we need to check that they are // hexadecimals. - return std::all_of(view.begin() + 2, view.end(), - ada::unicode::is_lowercase_hex); + view.remove_prefix(2); + return std::ranges::all_of(view, ada::unicode::is_lowercase_hex); } // for use with path_signature, we include all characters that need percent @@ -10421,6 +10421,8 @@ ADA_POP_DISABLE_WARNINGS #include #endif +#include + namespace ada::unicode { constexpr bool is_tabs_or_newline(char c) noexcept { @@ -10461,8 +10463,7 @@ ada_really_inline bool has_tabs_or_newline( std::string_view user_input) noexcept { // first check for short strings in which case we do it naively. if (user_input.size() < 16) { // slow path - return std::any_of(user_input.begin(), user_input.end(), - is_tabs_or_newline); + return std::ranges::any_of(user_input, is_tabs_or_newline); } // fast path for long strings (expected to be common) size_t i = 0; @@ -10500,8 +10501,7 @@ ada_really_inline bool has_tabs_or_newline( std::string_view user_input) noexcept { // first check for short strings in which case we do it naively. if (user_input.size() < 16) { // slow path - return std::any_of(user_input.begin(), user_input.end(), - is_tabs_or_newline); + return std::ranges::any_of(user_input, is_tabs_or_newline); } // fast path for long strings (expected to be common) size_t i = 0; @@ -10832,10 +10832,9 @@ bool percent_encode(const std::string_view input, const uint8_t character_set[], std::string& out) { ada_log("percent_encode ", input, " to output string while ", append ? "appending" : "overwriting"); - auto pointer = - std::find_if(input.begin(), input.end(), [character_set](const char c) { - return character_sets::bit_at(character_set, c); - }); + auto pointer = std::ranges::find_if(input, [character_set](const char c) { + return character_sets::bit_at(character_set, c); + }); ada_log("percent_encode done checking, moved to ", std::distance(input.begin(), pointer)); @@ -11850,6 +11849,7 @@ ada_warn_unused std::string to_string(ada::state state) { #include #include +#include #include #include @@ -11857,8 +11857,7 @@ namespace ada { bool url::parse_opaque_host(std::string_view input) { ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]"); - if (std::ranges::any_of(input.begin(), input.end(), - ada::unicode::is_forbidden_host_code_point)) { + if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) { return is_valid = false; } @@ -12725,6 +12724,7 @@ bool url::set_href(const std::string_view input) { /* begin file src/parser.cpp */ #include +#include namespace ada::parser { @@ -13344,7 +13344,7 @@ result_type parse_url_impl(std::string_view user_input, // to optimize it. if (view.ends_with(' ')) { std::string modified_view = - std::string(view.begin(), view.end() - 1) + "%20"; + std::string(view.substr(0, view.size() - 1)) + "%20"; url.update_base_pathname(unicode::percent_encode( modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE)); } else { @@ -13694,6 +13694,7 @@ namespace ada { /* end file src/url_components.cpp */ /* begin file src/url_aggregator.cpp */ +#include #include #include @@ -13913,7 +13914,7 @@ bool url_aggregator::set_protocol(const std::string_view input) { if (pointer != view.end() && *pointer == ':') { return parse_scheme_with_colon( - std::string_view(view.data(), pointer - view.begin() + 1)); + view.substr(0, pointer - view.begin() + 1)); } return false; } @@ -14175,8 +14176,8 @@ ada_really_inline bool url_aggregator::parse_host(std::string_view input) { ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(), " bytes]"); - if (std::any_of(host.value().begin(), host.value().end(), - ada::unicode::is_forbidden_domain_code_point)) { + if (std::ranges::any_of(host.value(), + ada::unicode::is_forbidden_domain_code_point)) { return is_valid = false; } @@ -14868,8 +14869,7 @@ bool url_aggregator::parse_opaque_host(std::string_view input) { ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]"); ADA_ASSERT_TRUE(validate()); ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer)); - if (std::any_of(input.begin(), input.end(), - ada::unicode::is_forbidden_host_code_point)) { + if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) { return is_valid = false; } diff --git a/deps/ada.h b/deps/ada.h index 071a54e..d1a6150 100644 --- a/deps/ada.h +++ b/deps/ada.h @@ -1,4 +1,4 @@ -/* auto-generated on 2025-04-24 20:04:09 -0400. Do not edit! */ +/* auto-generated on 2025-04-28 12:16:36 -0400. Do not edit! */ /* begin file include/ada.h */ /** * @file ada.h @@ -4115,7 +4115,6 @@ void swap(expected &lhs, #endif /* end file include/ada/expected.h */ -#if ADA_INCLUDE_URL_PATTERN /* begin file include/ada/url_pattern_regex.h */ /** * @file url_search_params.h @@ -4131,6 +4130,7 @@ void swap(expected &lhs, #include #endif // ADA_USE_UNSAFE_STD_REGEX_PROVIDER +#if ADA_INCLUDE_URL_PATTERN namespace ada::url_pattern_regex { template @@ -4175,7 +4175,7 @@ class std_regex_provider final { #endif // ADA_USE_UNSAFE_STD_REGEX_PROVIDER } // namespace ada::url_pattern_regex - +#endif // ADA_INCLUDE_URL_PATTERN #endif // ADA_URL_PATTERN_REGEX_H /* end file include/ada/url_pattern_regex.h */ /* begin file include/ada/url_pattern_init.h */ @@ -4209,6 +4209,7 @@ enum class errors : uint8_t { type_error }; #include #endif // ADA_TESTING +#if ADA_INCLUDE_URL_PATTERN namespace ada { // Important: C++20 allows us to use concept rather than `using` or `typedef @@ -4312,10 +4313,9 @@ struct url_pattern_init { std::optional base_url{}; }; } // namespace ada - +#endif // ADA_INCLUDE_URL_PATTERN #endif // ADA_URL_PATTERN_INIT_H /* end file include/ada/url_pattern_init.h */ -#endif // ADA_INCLUDE_URL_PATTERN /** * @private @@ -4378,7 +4378,6 @@ tl::expected, errors> parse_url_pattern_impl( #ifndef ADA_PARSER_INL_H #define ADA_PARSER_INL_H -#if ADA_INCLUDE_URL_PATTERN /* begin file include/ada/url_pattern.h */ /** * @file url_pattern.h @@ -5014,9 +5013,6 @@ inline std::ostream &operator<<(std::ostream &out, const ada::url &u); #endif // ADA_URL_H /* end file include/ada/url.h */ -#if ADA_INCLUDE_URL_PATTERN -#endif // ADA_INCLUDE_URL_PATTERN - namespace ada { template @@ -5088,6 +5084,7 @@ std::string href_from_file(std::string_view path); #include #endif // ADA_TESTING +#if ADA_INCLUDE_URL_PATTERN namespace ada { enum class url_pattern_part_type : uint8_t { @@ -5420,9 +5417,8 @@ class url_pattern { */ bool ignore_case_ = false; }; - } // namespace ada - +#endif // ADA_INCLUDE_URL_PATTERN #endif /* end file include/ada/url_pattern.h */ /* begin file include/ada/url_pattern_helpers.h */ @@ -5438,6 +5434,7 @@ class url_pattern { #include #include +#if ADA_INCLUDE_URL_PATTERN namespace ada { enum class errors : uint8_t; } @@ -5769,10 +5766,9 @@ std::string generate_segment_wildcard_regexp( url_pattern_compile_component_options options); } // namespace ada::url_pattern_helpers - +#endif // ADA_INCLUDE_URL_PATTERN #endif /* end file include/ada/url_pattern_helpers.h */ -#endif // ADA_INCLUDE_URL_PATTERN #include #include @@ -8915,7 +8911,6 @@ url_search_params_entries_iter::next() { #endif // ADA_URL_SEARCH_PARAMS_INL_H /* end file include/ada/url_search_params-inl.h */ -#if ADA_INCLUDE_URL_PATTERN /* begin file include/ada/url_pattern-inl.h */ /** * @file url_pattern-inl.h @@ -8929,6 +8924,7 @@ url_search_params_entries_iter::next() { #include #include +#if ADA_INCLUDE_URL_PATTERN namespace ada { inline bool url_pattern_init::operator==(const url_pattern_init& other) const { @@ -9397,7 +9393,7 @@ result> url_pattern::match( } } // namespace ada - +#endif // ADA_INCLUDE_URL_PATTERN #endif /* end file include/ada/url_pattern-inl.h */ /* begin file include/ada/url_pattern_helpers-inl.h */ @@ -9412,6 +9408,7 @@ result> url_pattern::match( #include +#if ADA_INCLUDE_URL_PATTERN namespace ada::url_pattern_helpers { #ifdef ADA_TESTING inline std::string to_string(token_type type) { @@ -10488,10 +10485,9 @@ constructor_string_parser::parse(std::string_view input) { } } // namespace ada::url_pattern_helpers - +#endif // ADA_INCLUDE_URL_PATTERN #endif /* end file include/ada/url_pattern_helpers-inl.h */ -#endif // ADA_INCLUDE_URL_PATTERN // Public API /* begin file include/ada/ada_version.h */ @@ -10502,14 +10498,14 @@ constructor_string_parser::parse(std::string_view input) { #ifndef ADA_ADA_VERSION_H #define ADA_ADA_VERSION_H -#define ADA_VERSION "3.2.3" +#define ADA_VERSION "3.2.4" namespace ada { enum { ADA_VERSION_MAJOR = 3, ADA_VERSION_MINOR = 2, - ADA_VERSION_REVISION = 3, + ADA_VERSION_REVISION = 4, }; } // namespace ada @@ -10523,8 +10519,6 @@ enum { #ifndef ADA_IMPLEMENTATION_INL_H #define ADA_IMPLEMENTATION_INL_H -#if ADA_INCLUDE_URL_PATTERN -#endif // ADA_INCLUDE_URL_PATTERN #include