Skip to content

Commit 0097d63

Browse files
authored
Changes for version 1.23.0 / ada 3.2.4 (#110)
1 parent 3a3c708 commit 0097d63

File tree

4 files changed

+62
-57
lines changed

4 files changed

+62
-57
lines changed

ada_url/ada.cpp

+45-35
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2025-03-30 13:24:42 -0400. Do not edit! */
1+
/* auto-generated on 2025-04-28 12:16:36 -0400. Do not edit! */
22
/* begin file src/ada.cpp */
33
#include "ada.h"
44
/* begin file src/checkers.cpp */
@@ -56,8 +56,8 @@ ada_really_inline constexpr bool is_ipv4(std::string_view view) noexcept {
5656
}
5757
// We have 0x followed by some characters, we need to check that they are
5858
// hexadecimals.
59-
return std::all_of(view.begin() + 2, view.end(),
60-
ada::unicode::is_lowercase_hex);
59+
view.remove_prefix(2);
60+
return std::ranges::all_of(view, ada::unicode::is_lowercase_hex);
6161
}
6262

6363
// for use with path_signature, we include all characters that need percent
@@ -10421,6 +10421,8 @@ ADA_POP_DISABLE_WARNINGS
1042110421
#include <emmintrin.h>
1042210422
#endif
1042310423

10424+
#include <ranges>
10425+
1042410426
namespace ada::unicode {
1042510427

1042610428
constexpr bool is_tabs_or_newline(char c) noexcept {
@@ -10461,8 +10463,7 @@ ada_really_inline bool has_tabs_or_newline(
1046110463
std::string_view user_input) noexcept {
1046210464
// first check for short strings in which case we do it naively.
1046310465
if (user_input.size() < 16) { // slow path
10464-
return std::any_of(user_input.begin(), user_input.end(),
10465-
is_tabs_or_newline);
10466+
return std::ranges::any_of(user_input, is_tabs_or_newline);
1046610467
}
1046710468
// fast path for long strings (expected to be common)
1046810469
size_t i = 0;
@@ -10500,8 +10501,7 @@ ada_really_inline bool has_tabs_or_newline(
1050010501
std::string_view user_input) noexcept {
1050110502
// first check for short strings in which case we do it naively.
1050210503
if (user_input.size() < 16) { // slow path
10503-
return std::any_of(user_input.begin(), user_input.end(),
10504-
is_tabs_or_newline);
10504+
return std::ranges::any_of(user_input, is_tabs_or_newline);
1050510505
}
1050610506
// fast path for long strings (expected to be common)
1050710507
size_t i = 0;
@@ -10832,10 +10832,9 @@ bool percent_encode(const std::string_view input, const uint8_t character_set[],
1083210832
std::string& out) {
1083310833
ada_log("percent_encode ", input, " to output string while ",
1083410834
append ? "appending" : "overwriting");
10835-
auto pointer =
10836-
std::find_if(input.begin(), input.end(), [character_set](const char c) {
10837-
return character_sets::bit_at(character_set, c);
10838-
});
10835+
auto pointer = std::ranges::find_if(input, [character_set](const char c) {
10836+
return character_sets::bit_at(character_set, c);
10837+
});
1083910838
ada_log("percent_encode done checking, moved to ",
1084010839
std::distance(input.begin(), pointer));
1084110840

@@ -11636,15 +11635,20 @@ ada_really_inline void parse_prepared_path(std::string_view input,
1163611635
// Note: input cannot be empty, it must at least contain one character ('.')
1163711636
// Note: we know that '\' is not present.
1163811637
if (input[0] != '.') {
11639-
size_t slashdot = input.find("/.");
11640-
if (slashdot == std::string_view::npos) { // common case
11641-
trivial_path = true;
11642-
} else { // uncommon
11643-
// only three cases matter: /./, /.. or a final /
11644-
trivial_path =
11645-
!(slashdot + 2 == input.size() || input[slashdot + 2] == '.' ||
11646-
input[slashdot + 2] == '/');
11638+
size_t slashdot = 0;
11639+
bool dot_is_file = true;
11640+
for (;;) {
11641+
slashdot = input.find("/.", slashdot);
11642+
if (slashdot == std::string_view::npos) { // common case
11643+
break;
11644+
} else { // uncommon
11645+
// only three cases matter: /./, /.. or a final /
11646+
slashdot += 2;
11647+
dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
11648+
input[slashdot] == '/');
11649+
}
1164711650
}
11651+
trivial_path = dot_is_file;
1164811652
}
1164911653
}
1165011654
if (trivial_path) {
@@ -11845,15 +11849,15 @@ ada_warn_unused std::string to_string(ada::state state) {
1184511849

1184611850
#include <numeric>
1184711851
#include <algorithm>
11852+
#include <ranges>
1184811853
#include <string>
1184911854
#include <string_view>
1185011855

1185111856
namespace ada {
1185211857

1185311858
bool url::parse_opaque_host(std::string_view input) {
1185411859
ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
11855-
if (std::ranges::any_of(input.begin(), input.end(),
11856-
ada::unicode::is_forbidden_host_code_point)) {
11860+
if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) {
1185711861
return is_valid = false;
1185811862
}
1185911863

@@ -12720,6 +12724,7 @@ bool url::set_href(const std::string_view input) {
1272012724
/* begin file src/parser.cpp */
1272112725

1272212726
#include <limits>
12727+
#include <ranges>
1272312728

1272412729

1272512730
namespace ada::parser {
@@ -13339,7 +13344,7 @@ result_type parse_url_impl(std::string_view user_input,
1333913344
// to optimize it.
1334013345
if (view.ends_with(' ')) {
1334113346
std::string modified_view =
13342-
std::string(view.begin(), view.end() - 1) + "%20";
13347+
std::string(view.substr(0, view.size() - 1)) + "%20";
1334313348
url.update_base_pathname(unicode::percent_encode(
1334413349
modified_view, character_sets::C0_CONTROL_PERCENT_ENCODE));
1334513350
} else {
@@ -13689,6 +13694,7 @@ namespace ada {
1368913694
/* end file src/url_components.cpp */
1369013695
/* begin file src/url_aggregator.cpp */
1369113696

13697+
#include <ranges>
1369213698
#include <string>
1369313699
#include <string_view>
1369413700

@@ -13908,7 +13914,7 @@ bool url_aggregator::set_protocol(const std::string_view input) {
1390813914

1390913915
if (pointer != view.end() && *pointer == ':') {
1391013916
return parse_scheme_with_colon<true>(
13911-
std::string_view(view.data(), pointer - view.begin() + 1));
13917+
view.substr(0, pointer - view.begin() + 1));
1391213918
}
1391313919
return false;
1391413920
}
@@ -14170,8 +14176,8 @@ ada_really_inline bool url_aggregator::parse_host(std::string_view input) {
1417014176
ada_log("parse_host to_ascii succeeded ", *host, " [", host->size(),
1417114177
" bytes]");
1417214178

14173-
if (std::any_of(host.value().begin(), host.value().end(),
14174-
ada::unicode::is_forbidden_domain_code_point)) {
14179+
if (std::ranges::any_of(host.value(),
14180+
ada::unicode::is_forbidden_domain_code_point)) {
1417514181
return is_valid = false;
1417614182
}
1417714183

@@ -14863,8 +14869,7 @@ bool url_aggregator::parse_opaque_host(std::string_view input) {
1486314869
ada_log("parse_opaque_host ", input, " [", input.size(), " bytes]");
1486414870
ADA_ASSERT_TRUE(validate());
1486514871
ADA_ASSERT_TRUE(!helpers::overlaps(input, buffer));
14866-
if (std::any_of(input.begin(), input.end(),
14867-
ada::unicode::is_forbidden_host_code_point)) {
14872+
if (std::ranges::any_of(input, ada::unicode::is_forbidden_host_code_point)) {
1486814873
return is_valid = false;
1486914874
}
1487014875

@@ -15093,15 +15098,20 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) {
1509315098
// Note: input cannot be empty, it must at least contain one character ('.')
1509415099
// Note: we know that '\' is not present.
1509515100
if (input[0] != '.') {
15096-
size_t slashdot = input.find("/.");
15097-
if (slashdot == std::string_view::npos) { // common case
15098-
trivial_path = true;
15099-
} else { // uncommon
15100-
// only three cases matter: /./, /.. or a final /
15101-
trivial_path =
15102-
!(slashdot + 2 == input.size() || input[slashdot + 2] == '.' ||
15103-
input[slashdot + 2] == '/');
15101+
size_t slashdot = 0;
15102+
bool dot_is_file = true;
15103+
for (;;) {
15104+
slashdot = input.find("/.", slashdot);
15105+
if (slashdot == std::string_view::npos) { // common case
15106+
break;
15107+
} else { // uncommon
15108+
// only three cases matter: /./, /.. or a final /
15109+
slashdot += 2;
15110+
dot_is_file &= !(slashdot == input.size() || input[slashdot] == '.' ||
15111+
input[slashdot] == '/');
15112+
}
1510415113
}
15114+
trivial_path = dot_is_file;
1510515115
}
1510615116
}
1510715117
if (trivial_path && is_at_path()) {

ada_url/ada.h

+15-21
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* auto-generated on 2025-03-30 13:24:42 -0400. Do not edit! */
1+
/* auto-generated on 2025-04-28 12:16:36 -0400. Do not edit! */
22
/* begin file include/ada.h */
33
/**
44
* @file ada.h
@@ -4115,7 +4115,6 @@ void swap(expected<T, E> &lhs,
41154115
#endif
41164116
/* end file include/ada/expected.h */
41174117

4118-
#if ADA_INCLUDE_URL_PATTERN
41194118
/* begin file include/ada/url_pattern_regex.h */
41204119
/**
41214120
* @file url_search_params.h
@@ -4131,6 +4130,7 @@ void swap(expected<T, E> &lhs,
41314130
#include <regex>
41324131
#endif // ADA_USE_UNSAFE_STD_REGEX_PROVIDER
41334132

4133+
#if ADA_INCLUDE_URL_PATTERN
41344134
namespace ada::url_pattern_regex {
41354135

41364136
template <typename T>
@@ -4175,7 +4175,7 @@ class std_regex_provider final {
41754175
#endif // ADA_USE_UNSAFE_STD_REGEX_PROVIDER
41764176

41774177
} // namespace ada::url_pattern_regex
4178-
4178+
#endif // ADA_INCLUDE_URL_PATTERN
41794179
#endif // ADA_URL_PATTERN_REGEX_H
41804180
/* end file include/ada/url_pattern_regex.h */
41814181
/* begin file include/ada/url_pattern_init.h */
@@ -4209,6 +4209,7 @@ enum class errors : uint8_t { type_error };
42094209
#include <iostream>
42104210
#endif // ADA_TESTING
42114211

4212+
#if ADA_INCLUDE_URL_PATTERN
42124213
namespace ada {
42134214

42144215
// Important: C++20 allows us to use concept rather than `using` or `typedef
@@ -4312,10 +4313,9 @@ struct url_pattern_init {
43124313
std::optional<std::string> base_url{};
43134314
};
43144315
} // namespace ada
4315-
4316+
#endif // ADA_INCLUDE_URL_PATTERN
43164317
#endif // ADA_URL_PATTERN_INIT_H
43174318
/* end file include/ada/url_pattern_init.h */
4318-
#endif // ADA_INCLUDE_URL_PATTERN
43194319

43204320
/**
43214321
* @private
@@ -4378,7 +4378,6 @@ tl::expected<url_pattern<regex_provider>, errors> parse_url_pattern_impl(
43784378
#ifndef ADA_PARSER_INL_H
43794379
#define ADA_PARSER_INL_H
43804380

4381-
#if ADA_INCLUDE_URL_PATTERN
43824381
/* begin file include/ada/url_pattern.h */
43834382
/**
43844383
* @file url_pattern.h
@@ -5014,9 +5013,6 @@ inline std::ostream &operator<<(std::ostream &out, const ada::url &u);
50145013
#endif // ADA_URL_H
50155014
/* end file include/ada/url.h */
50165015

5017-
#if ADA_INCLUDE_URL_PATTERN
5018-
#endif // ADA_INCLUDE_URL_PATTERN
5019-
50205016
namespace ada {
50215017

50225018
template <class result_type = ada::url_aggregator>
@@ -5088,6 +5084,7 @@ std::string href_from_file(std::string_view path);
50885084
#include <iostream>
50895085
#endif // ADA_TESTING
50905086

5087+
#if ADA_INCLUDE_URL_PATTERN
50915088
namespace ada {
50925089

50935090
enum class url_pattern_part_type : uint8_t {
@@ -5420,9 +5417,8 @@ class url_pattern {
54205417
*/
54215418
bool ignore_case_ = false;
54225419
};
5423-
54245420
} // namespace ada
5425-
5421+
#endif // ADA_INCLUDE_URL_PATTERN
54265422
#endif
54275423
/* end file include/ada/url_pattern.h */
54285424
/* begin file include/ada/url_pattern_helpers.h */
@@ -5438,6 +5434,7 @@ class url_pattern {
54385434
#include <tuple>
54395435
#include <vector>
54405436

5437+
#if ADA_INCLUDE_URL_PATTERN
54415438
namespace ada {
54425439
enum class errors : uint8_t;
54435440
}
@@ -5769,10 +5766,9 @@ std::string generate_segment_wildcard_regexp(
57695766
url_pattern_compile_component_options options);
57705767

57715768
} // namespace ada::url_pattern_helpers
5772-
5769+
#endif // ADA_INCLUDE_URL_PATTERN
57735770
#endif
57745771
/* end file include/ada/url_pattern_helpers.h */
5775-
#endif // ADA_INCLUDE_URL_PATTERN
57765772

57775773
#include <string>
57785774
#include <string_view>
@@ -8915,7 +8911,6 @@ url_search_params_entries_iter::next() {
89158911
#endif // ADA_URL_SEARCH_PARAMS_INL_H
89168912
/* end file include/ada/url_search_params-inl.h */
89178913

8918-
#if ADA_INCLUDE_URL_PATTERN
89198914
/* begin file include/ada/url_pattern-inl.h */
89208915
/**
89218916
* @file url_pattern-inl.h
@@ -8929,6 +8924,7 @@ url_search_params_entries_iter::next() {
89298924
#include <string_view>
89308925
#include <utility>
89318926

8927+
#if ADA_INCLUDE_URL_PATTERN
89328928
namespace ada {
89338929

89348930
inline bool url_pattern_init::operator==(const url_pattern_init& other) const {
@@ -9397,7 +9393,7 @@ result<std::optional<url_pattern_result>> url_pattern<regex_provider>::match(
93979393
}
93989394

93999395
} // namespace ada
9400-
9396+
#endif // ADA_INCLUDE_URL_PATTERN
94019397
#endif
94029398
/* end file include/ada/url_pattern-inl.h */
94039399
/* begin file include/ada/url_pattern_helpers-inl.h */
@@ -9412,6 +9408,7 @@ result<std::optional<url_pattern_result>> url_pattern<regex_provider>::match(
94129408
#include <string_view>
94139409

94149410

9411+
#if ADA_INCLUDE_URL_PATTERN
94159412
namespace ada::url_pattern_helpers {
94169413
#ifdef ADA_TESTING
94179414
inline std::string to_string(token_type type) {
@@ -10488,10 +10485,9 @@ constructor_string_parser<regex_provider>::parse(std::string_view input) {
1048810485
}
1048910486

1049010487
} // namespace ada::url_pattern_helpers
10491-
10488+
#endif // ADA_INCLUDE_URL_PATTERN
1049210489
#endif
1049310490
/* end file include/ada/url_pattern_helpers-inl.h */
10494-
#endif // ADA_INCLUDE_URL_PATTERN
1049510491

1049610492
// Public API
1049710493
/* begin file include/ada/ada_version.h */
@@ -10502,14 +10498,14 @@ constructor_string_parser<regex_provider>::parse(std::string_view input) {
1050210498
#ifndef ADA_ADA_VERSION_H
1050310499
#define ADA_ADA_VERSION_H
1050410500

10505-
#define ADA_VERSION "3.2.2"
10501+
#define ADA_VERSION "3.2.4"
1050610502

1050710503
namespace ada {
1050810504

1050910505
enum {
1051010506
ADA_VERSION_MAJOR = 3,
1051110507
ADA_VERSION_MINOR = 2,
10512-
ADA_VERSION_REVISION = 2,
10508+
ADA_VERSION_REVISION = 4,
1051310509
};
1051410510

1051510511
} // namespace ada
@@ -10523,8 +10519,6 @@ enum {
1052310519
#ifndef ADA_IMPLEMENTATION_INL_H
1052410520
#define ADA_IMPLEMENTATION_INL_H
1052510521

10526-
#if ADA_INCLUDE_URL_PATTERN
10527-
#endif // ADA_INCLUDE_URL_PATTERN
1052810522

1052910523

1053010524
#include <variant>

ada_url/ada_build.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
ada_obj = Extension(
1111
'ada',
12+
define_macros=[('ADA_INCLUDE_URL_PATTERN', '0')],
1213
language="c++",
1314
sources=['ada_url/ada.cpp'],
1415
include_dirs=[file_dir],

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "ada-url"
7-
version = "1.22.0"
7+
version = "1.23.0"
88
authors = [
99
{name = "Bo Bayles", email = "[email protected]"},
1010
]

0 commit comments

Comments
 (0)