1
- /* auto-generated on 2023-04-26 16:43:37 -0400. Do not edit! */
1
+ /* auto-generated on 2023-05-05 22:58:51 -0400. Do not edit! */
2
2
/* begin file src/ada.cpp */
3
3
#include "ada.h"
4
4
/* begin file src/checkers.cpp */
@@ -10410,6 +10410,19 @@ std::string href_from_file(std::string_view input) {
10410
10410
return "file://" + path;
10411
10411
}
10412
10412
10413
+ bool can_parse(std::string_view input, std::string_view* base_input = nullptr) {
10414
+ ada::result<ada::url_aggregator> base;
10415
+ ada::url_aggregator* base_pointer = nullptr;
10416
+ if (base_input != nullptr) {
10417
+ base = ada::parse<url_aggregator>(*base_input);
10418
+ if (!base) {
10419
+ return false;
10420
+ }
10421
+ base_pointer = &base.value();
10422
+ }
10423
+ return ada::parse<url_aggregator>(input, base_pointer).has_value();
10424
+ }
10425
+
10413
10426
ada_warn_unused std::string to_string(ada::encoding_type type) {
10414
10427
switch (type) {
10415
10428
case ada::encoding_type::UTF8:
@@ -10536,8 +10549,9 @@ ada_really_inline bool shorten_path(std::string& path,
10536
10549
}
10537
10550
10538
10551
// Remove path’s last item, if any.
10539
- if (!path.empty()) {
10540
- path.erase(path.rfind('/'));
10552
+ size_t last_delimiter = path.rfind('/');
10553
+ if (last_delimiter != std::string::npos) {
10554
+ path.erase(last_delimiter);
10541
10555
return true;
10542
10556
}
10543
10557
@@ -10564,8 +10578,8 @@ ada_really_inline bool shorten_path(std::string_view& path,
10564
10578
size_t slash_loc = path.rfind('/');
10565
10579
if (slash_loc != std::string_view::npos) {
10566
10580
path.remove_suffix(path.size() - slash_loc);
10581
+ return true;
10567
10582
}
10568
- return true;
10569
10583
}
10570
10584
10571
10585
return false;
@@ -10929,8 +10943,9 @@ ada_really_inline void parse_prepared_path(std::string_view input,
10929
10943
input.substr(previous_location, new_location - previous_location);
10930
10944
previous_location = new_location + 1;
10931
10945
if (path_view == "..") {
10932
- if (!path.empty()) {
10933
- path.erase(path.rfind('/'));
10946
+ size_t last_delimiter = path.rfind('/');
10947
+ if (last_delimiter != std::string::npos) {
10948
+ path.erase(last_delimiter);
10934
10949
}
10935
10950
} else if (path_view != ".") {
10936
10951
path += '/';
@@ -10961,8 +10976,8 @@ ada_really_inline void parse_prepared_path(std::string_view input,
10961
10976
? path_buffer_tmp
10962
10977
: path_view;
10963
10978
if (unicode::is_double_dot_path_segment(path_buffer)) {
10964
- helpers::shorten_path(path, type);
10965
- if ( location == std::string_view::npos) {
10979
+ if (( helpers::shorten_path(path, type) || special) &&
10980
+ location == std::string_view::npos) {
10966
10981
path += '/';
10967
10982
}
10968
10983
} else if (unicode::is_single_dot_path_segment(path_buffer) &&
@@ -12073,9 +12088,9 @@ result_type parse_url(std::string_view user_input,
12073
12088
std::string_view::size_type(std::numeric_limits<uint32_t>::max)) {
12074
12089
url.is_valid = false;
12075
12090
}
12076
-
12077
- // If we are provided with an invalid base, or the optional_url was invalid,
12078
- // we must return.
12091
+ // Going forward, user_input.size() is in [0,
12092
+ // std::numeric_limits<uint32_t>::max). If we are provided with an invalid
12093
+ // base, or the optional_url was invalid, we must return.
12079
12094
if (base_url != nullptr) {
12080
12095
url.is_valid &= base_url->is_valid;
12081
12096
}
@@ -12092,8 +12107,11 @@ result_type parse_url(std::string_view user_input,
12092
12107
// it may not matter, but in other instances, it could.
12093
12108
////
12094
12109
// This rounds up to the next power of two.
12110
+ // We know that user_input.size() is in [0,
12111
+ // std::numeric_limits<uint32_t>::max).
12095
12112
uint32_t reserve_capacity =
12096
- (0xFFFFFFFF >> helpers::leading_zeroes(uint32_t(user_input.size()))) +
12113
+ (0xFFFFFFFF >>
12114
+ helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
12097
12115
1;
12098
12116
url.reserve(reserve_capacity);
12099
12117
//
@@ -12451,6 +12469,8 @@ result_type parse_url(std::string_view user_input,
12451
12469
url.password = base_url->password;
12452
12470
url.host = base_url->host;
12453
12471
url.port = base_url->port;
12472
+ // cloning the base path includes cloning the has_opaque_path flag
12473
+ url.has_opaque_path = base_url->has_opaque_path;
12454
12474
url.path = base_url->path;
12455
12475
url.query = base_url->query;
12456
12476
} else {
@@ -12460,6 +12480,8 @@ result_type parse_url(std::string_view user_input,
12460
12480
// update_base_hostname
12461
12481
url.set_hostname(base_url->get_hostname());
12462
12482
url.update_base_port(base_url->retrieve_base_port());
12483
+ // cloning the base path includes cloning the has_opaque_path flag
12484
+ url.has_opaque_path = base_url->has_opaque_path;
12463
12485
url.update_base_pathname(base_url->get_pathname());
12464
12486
url.update_base_search(base_url->get_search());
12465
12487
}
@@ -12891,7 +12913,6 @@ result_type parse_url(std::string_view user_input,
12891
12913
else if (input_position != input_size) {
12892
12914
// Set url’s query to null.
12893
12915
url.clear_search();
12894
-
12895
12916
// If the code point substring from pointer to the end of input does
12896
12917
// not start with a Windows drive letter, then shorten url’s path.
12897
12918
if (!checkers::is_windows_drive_letter(file_view)) {
@@ -14714,8 +14735,9 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) {
14714
14735
input.substr(previous_location, new_location - previous_location);
14715
14736
previous_location = new_location + 1;
14716
14737
if (path_view == "..") {
14717
- if (!path.empty()) {
14718
- path.erase(path.rfind('/'));
14738
+ size_t last_delimiter = path.rfind('/');
14739
+ if (last_delimiter != std::string::npos) {
14740
+ path.erase(last_delimiter);
14719
14741
}
14720
14742
} else if (path_view != ".") {
14721
14743
path += '/';
@@ -14746,8 +14768,8 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) {
14746
14768
? path_buffer_tmp
14747
14769
: path_view;
14748
14770
if (unicode::is_double_dot_path_segment(path_buffer)) {
14749
- helpers::shorten_path(path, type);
14750
- if ( location == std::string_view::npos) {
14771
+ if (( helpers::shorten_path(path, type) || special) &&
14772
+ location == std::string_view::npos) {
14751
14773
path += '/';
14752
14774
}
14753
14775
} else if (unicode::is_single_dot_path_segment(path_buffer) &&
0 commit comments