Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: update ada to 2.3.1 #47893

Merged
merged 1 commit into from
May 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
56 changes: 39 additions & 17 deletions deps/ada/ada.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* auto-generated on 2023-04-26 16:43:37 -0400. Do not edit! */
/* auto-generated on 2023-05-05 22:58:51 -0400. Do not edit! */
/* begin file src/ada.cpp */
#include "ada.h"
/* begin file src/checkers.cpp */
Expand Down Expand Up @@ -10410,6 +10410,19 @@ std::string href_from_file(std::string_view input) {
return "file://" + path;
}

bool can_parse(std::string_view input, std::string_view* base_input = nullptr) {
ada::result<ada::url_aggregator> base;
ada::url_aggregator* base_pointer = nullptr;
if (base_input != nullptr) {
base = ada::parse<url_aggregator>(*base_input);
if (!base) {
return false;
}
base_pointer = &base.value();
}
return ada::parse<url_aggregator>(input, base_pointer).has_value();
}

ada_warn_unused std::string to_string(ada::encoding_type type) {
switch (type) {
case ada::encoding_type::UTF8:
Expand Down Expand Up @@ -10536,8 +10549,9 @@ ada_really_inline bool shorten_path(std::string& path,
}

// Remove path’s last item, if any.
if (!path.empty()) {
path.erase(path.rfind('/'));
size_t last_delimiter = path.rfind('/');
if (last_delimiter != std::string::npos) {
path.erase(last_delimiter);
return true;
}

Expand All @@ -10564,8 +10578,8 @@ ada_really_inline bool shorten_path(std::string_view& path,
size_t slash_loc = path.rfind('/');
if (slash_loc != std::string_view::npos) {
path.remove_suffix(path.size() - slash_loc);
return true;
}
return true;
}

return false;
Expand Down Expand Up @@ -10929,8 +10943,9 @@ ada_really_inline void parse_prepared_path(std::string_view input,
input.substr(previous_location, new_location - previous_location);
previous_location = new_location + 1;
if (path_view == "..") {
if (!path.empty()) {
path.erase(path.rfind('/'));
size_t last_delimiter = path.rfind('/');
if (last_delimiter != std::string::npos) {
path.erase(last_delimiter);
}
} else if (path_view != ".") {
path += '/';
Expand Down Expand Up @@ -10961,8 +10976,8 @@ ada_really_inline void parse_prepared_path(std::string_view input,
? path_buffer_tmp
: path_view;
if (unicode::is_double_dot_path_segment(path_buffer)) {
helpers::shorten_path(path, type);
if (location == std::string_view::npos) {
if ((helpers::shorten_path(path, type) || special) &&
location == std::string_view::npos) {
path += '/';
}
} else if (unicode::is_single_dot_path_segment(path_buffer) &&
Expand Down Expand Up @@ -12073,9 +12088,9 @@ result_type parse_url(std::string_view user_input,
std::string_view::size_type(std::numeric_limits<uint32_t>::max)) {
url.is_valid = false;
}

// If we are provided with an invalid base, or the optional_url was invalid,
// we must return.
// Going forward, user_input.size() is in [0,
// std::numeric_limits<uint32_t>::max). If we are provided with an invalid
// base, or the optional_url was invalid, we must return.
if (base_url != nullptr) {
url.is_valid &= base_url->is_valid;
}
Expand All @@ -12092,8 +12107,11 @@ result_type parse_url(std::string_view user_input,
// it may not matter, but in other instances, it could.
////
// This rounds up to the next power of two.
// We know that user_input.size() is in [0,
// std::numeric_limits<uint32_t>::max).
uint32_t reserve_capacity =
(0xFFFFFFFF >> helpers::leading_zeroes(uint32_t(user_input.size()))) +
(0xFFFFFFFF >>
helpers::leading_zeroes(uint32_t(1 | user_input.size()))) +
1;
url.reserve(reserve_capacity);
//
Expand Down Expand Up @@ -12451,6 +12469,8 @@ result_type parse_url(std::string_view user_input,
url.password = base_url->password;
url.host = base_url->host;
url.port = base_url->port;
// cloning the base path includes cloning the has_opaque_path flag
url.has_opaque_path = base_url->has_opaque_path;
url.path = base_url->path;
url.query = base_url->query;
} else {
Expand All @@ -12460,6 +12480,8 @@ result_type parse_url(std::string_view user_input,
// update_base_hostname
url.set_hostname(base_url->get_hostname());
url.update_base_port(base_url->retrieve_base_port());
// cloning the base path includes cloning the has_opaque_path flag
url.has_opaque_path = base_url->has_opaque_path;
url.update_base_pathname(base_url->get_pathname());
url.update_base_search(base_url->get_search());
}
Expand Down Expand Up @@ -12891,7 +12913,6 @@ result_type parse_url(std::string_view user_input,
else if (input_position != input_size) {
// Set url’s query to null.
url.clear_search();

// If the code point substring from pointer to the end of input does
// not start with a Windows drive letter, then shorten url’s path.
if (!checkers::is_windows_drive_letter(file_view)) {
Expand Down Expand Up @@ -14714,8 +14735,9 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) {
input.substr(previous_location, new_location - previous_location);
previous_location = new_location + 1;
if (path_view == "..") {
if (!path.empty()) {
path.erase(path.rfind('/'));
size_t last_delimiter = path.rfind('/');
if (last_delimiter != std::string::npos) {
path.erase(last_delimiter);
}
} else if (path_view != ".") {
path += '/';
Expand Down Expand Up @@ -14746,8 +14768,8 @@ inline void url_aggregator::consume_prepared_path(std::string_view input) {
? path_buffer_tmp
: path_view;
if (unicode::is_double_dot_path_segment(path_buffer)) {
helpers::shorten_path(path, type);
if (location == std::string_view::npos) {
if ((helpers::shorten_path(path, type) || special) &&
location == std::string_view::npos) {
path += '/';
}
} else if (unicode::is_single_dot_path_segment(path_buffer) &&
Expand Down
16 changes: 10 additions & 6 deletions deps/ada/ada.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* auto-generated on 2023-04-26 16:43:37 -0400. Do not edit! */
/* auto-generated on 2023-05-05 22:58:51 -0400. Do not edit! */
/* begin file include/ada.h */
/**
* @file ada.h
Expand Down Expand Up @@ -5398,9 +5398,7 @@ size_t url::get_pathname_length() const noexcept { return path.size(); }

out.pathname_start = uint32_t(running_index);

if (!path.empty()) {
running_index += path.size();
}
running_index += path.size();

if (query.has_value()) {
out.search_start = uint32_t(running_index);
Expand Down Expand Up @@ -6475,14 +6473,14 @@ inline std::ostream &operator<<(std::ostream &out,
#ifndef ADA_ADA_VERSION_H
#define ADA_ADA_VERSION_H

#define ADA_VERSION "2.3.0"
#define ADA_VERSION "2.3.1"

namespace ada {

enum {
ADA_VERSION_MAJOR = 2,
ADA_VERSION_MINOR = 3,
ADA_VERSION_REVISION = 0,
ADA_VERSION_REVISION = 1,
};

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

/**
* @see https://url.spec.whatwg.org/#dom-url-canparse
* @return If URL can be parsed or not.
*/
bool can_parse(std::string_view input, std::string_view* base_input);

/**
* Computes a href string from a file path.
* @return a href string (starts with file:://)
Expand Down