Skip to content

Commit 3cf335c

Browse files
nodejs-github-botanonrig
authored andcommitted
deps: update ada to 2.3.1
PR-URL: nodejs#47893 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 145a7ad commit 3cf335c

File tree

2 files changed

+49
-23
lines changed

2 files changed

+49
-23
lines changed

deps/ada/ada.cpp

+39-17
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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! */
22
/* begin file src/ada.cpp */
33
#include "ada.h"
44
/* begin file src/checkers.cpp */
@@ -10410,6 +10410,19 @@ std::string href_from_file(std::string_view input) {
1041010410
return "file://" + path;
1041110411
}
1041210412

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+
1041310426
ada_warn_unused std::string to_string(ada::encoding_type type) {
1041410427
switch (type) {
1041510428
case ada::encoding_type::UTF8:
@@ -10536,8 +10549,9 @@ ada_really_inline bool shorten_path(std::string& path,
1053610549
}
1053710550

1053810551
// 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);
1054110555
return true;
1054210556
}
1054310557

@@ -10564,8 +10578,8 @@ ada_really_inline bool shorten_path(std::string_view& path,
1056410578
size_t slash_loc = path.rfind('/');
1056510579
if (slash_loc != std::string_view::npos) {
1056610580
path.remove_suffix(path.size() - slash_loc);
10581+
return true;
1056710582
}
10568-
return true;
1056910583
}
1057010584

1057110585
return false;
@@ -10929,8 +10943,9 @@ ada_really_inline void parse_prepared_path(std::string_view input,
1092910943
input.substr(previous_location, new_location - previous_location);
1093010944
previous_location = new_location + 1;
1093110945
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);
1093410949
}
1093510950
} else if (path_view != ".") {
1093610951
path += '/';
@@ -10961,8 +10976,8 @@ ada_really_inline void parse_prepared_path(std::string_view input,
1096110976
? path_buffer_tmp
1096210977
: path_view;
1096310978
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) {
1096610981
path += '/';
1096710982
}
1096810983
} else if (unicode::is_single_dot_path_segment(path_buffer) &&
@@ -12073,9 +12088,9 @@ result_type parse_url(std::string_view user_input,
1207312088
std::string_view::size_type(std::numeric_limits<uint32_t>::max)) {
1207412089
url.is_valid = false;
1207512090
}
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.
1207912094
if (base_url != nullptr) {
1208012095
url.is_valid &= base_url->is_valid;
1208112096
}
@@ -12092,8 +12107,11 @@ result_type parse_url(std::string_view user_input,
1209212107
// it may not matter, but in other instances, it could.
1209312108
////
1209412109
// 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).
1209512112
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()))) +
1209712115
1;
1209812116
url.reserve(reserve_capacity);
1209912117
//
@@ -12451,6 +12469,8 @@ result_type parse_url(std::string_view user_input,
1245112469
url.password = base_url->password;
1245212470
url.host = base_url->host;
1245312471
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;
1245412474
url.path = base_url->path;
1245512475
url.query = base_url->query;
1245612476
} else {
@@ -12460,6 +12480,8 @@ result_type parse_url(std::string_view user_input,
1246012480
// update_base_hostname
1246112481
url.set_hostname(base_url->get_hostname());
1246212482
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;
1246312485
url.update_base_pathname(base_url->get_pathname());
1246412486
url.update_base_search(base_url->get_search());
1246512487
}
@@ -12891,7 +12913,6 @@ result_type parse_url(std::string_view user_input,
1289112913
else if (input_position != input_size) {
1289212914
// Set url’s query to null.
1289312915
url.clear_search();
12894-
1289512916
// If the code point substring from pointer to the end of input does
1289612917
// not start with a Windows drive letter, then shorten url’s path.
1289712918
if (!checkers::is_windows_drive_letter(file_view)) {
@@ -14714,8 +14735,9 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) {
1471414735
input.substr(previous_location, new_location - previous_location);
1471514736
previous_location = new_location + 1;
1471614737
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);
1471914741
}
1472014742
} else if (path_view != ".") {
1472114743
path += '/';
@@ -14746,8 +14768,8 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) {
1474614768
? path_buffer_tmp
1474714769
: path_view;
1474814770
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) {
1475114773
path += '/';
1475214774
}
1475314775
} else if (unicode::is_single_dot_path_segment(path_buffer) &&

deps/ada/ada.h

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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! */
22
/* begin file include/ada.h */
33
/**
44
* @file ada.h
@@ -5398,9 +5398,7 @@ size_t url::get_pathname_length() const noexcept { return path.size(); }
53985398

53995399
out.pathname_start = uint32_t(running_index);
54005400

5401-
if (!path.empty()) {
5402-
running_index += path.size();
5403-
}
5401+
running_index += path.size();
54045402

54055403
if (query.has_value()) {
54065404
out.search_start = uint32_t(running_index);
@@ -6475,14 +6473,14 @@ inline std::ostream &operator<<(std::ostream &out,
64756473
#ifndef ADA_ADA_VERSION_H
64766474
#define ADA_ADA_VERSION_H
64776475

6478-
#define ADA_VERSION "2.3.0"
6476+
#define ADA_VERSION "2.3.1"
64796477

64806478
namespace ada {
64816479

64826480
enum {
64836481
ADA_VERSION_MAJOR = 2,
64846482
ADA_VERSION_MINOR = 3,
6485-
ADA_VERSION_REVISION = 0,
6483+
ADA_VERSION_REVISION = 1,
64866484
};
64876485

64886486
} // namespace ada
@@ -6526,6 +6524,12 @@ extern template ada::result<url> parse<url>(std::string_view input,
65266524
extern template ada::result<url_aggregator> parse<url_aggregator>(
65276525
std::string_view input, const url_aggregator* base_url);
65286526

6527+
/**
6528+
* @see https://url.spec.whatwg.org/#dom-url-canparse
6529+
* @return If URL can be parsed or not.
6530+
*/
6531+
bool can_parse(std::string_view input, std::string_view* base_input);
6532+
65296533
/**
65306534
* Computes a href string from a file path.
65316535
* @return a href string (starts with file:://)

0 commit comments

Comments
 (0)