Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/ada/ada_idna.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace ada::idna {
/**
* @see https://www.unicode.org/reports/tr46/#Validity_Criteria
*/
bool is_label_valid(const std::u32string_view label);
bool is_label_valid(std::u32string_view label);

} // namespace ada::idna

Expand Down
2 changes: 1 addition & 1 deletion include/ada/character_sets-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,4 +513,4 @@ ada_really_inline bool bit_at(const uint8_t a[], const uint8_t i) {

} // namespace ada::character_sets

#endif // ADA_CHARACTER_SETS_H
#endif // ADA_CHARACTER_SETS_INL_H
4 changes: 2 additions & 2 deletions include/ada/character_sets.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
#define ADA_CHARACTER_SETS_H

#include "ada/common_defs.h"
#include <stdint.h>
#include <cstdint>

/**
* @namespace ada::character_sets
* @brief Includes the definitions for unicode character sets.
*/
namespace ada::character_sets {
ada_really_inline bool bit_at(const uint8_t a[], const uint8_t i);
ada_really_inline bool bit_at(const uint8_t a[], uint8_t i);
} // namespace ada::character_sets

#endif // ADA_CHARACTER_SETS_H
2 changes: 1 addition & 1 deletion include/ada/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ ada_really_inline bool shorten_path(std::string_view& path,
*
* @see https://url.spec.whatwg.org/
*/
ada_really_inline void parse_prepared_path(const std::string_view input,
ada_really_inline void parse_prepared_path(std::string_view input,
ada::scheme::type type,
std::string& path);

Expand Down
2 changes: 1 addition & 1 deletion include/ada/scheme-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ constexpr ada::scheme::type get_scheme_type(std::string_view scheme) noexcept {

} // namespace ada::scheme

#endif // ADA_SCHEME_H
#endif // ADA_SCHEME_INL_H
2 changes: 1 addition & 1 deletion include/ada/serializers.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ std::string ipv6(const std::array<uint16_t, 8>& address) noexcept;
* network address.
* @see https://url.spec.whatwg.org/#concept-ipv4-serializer
*/
std::string ipv4(const uint64_t address) noexcept;
std::string ipv4(uint64_t address) noexcept;

} // namespace ada::serializers

Expand Down
29 changes: 14 additions & 15 deletions include/ada/unicode.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ ada_really_inline bool has_tabs_or_newline(
* Checks if the input is a forbidden host code point.
* @see https://url.spec.whatwg.org/#forbidden-host-code-point
*/
ada_really_inline constexpr bool is_forbidden_host_code_point(
const char c) noexcept;
ada_really_inline constexpr bool is_forbidden_host_code_point(char c) noexcept;

/**
* Checks if the input contains a forbidden domain code point.
Expand All @@ -103,20 +102,20 @@ contains_forbidden_domain_code_point_or_upper(const char* input,
* @see https://url.spec.whatwg.org/#forbidden-domain-code-point
*/
ada_really_inline constexpr bool is_forbidden_domain_code_point(
const char c) noexcept;
char c) noexcept;

/**
* Checks if the input is alphanumeric, '+', '-' or '.'
*/
ada_really_inline constexpr bool is_alnum_plus(const char c) noexcept;
ada_really_inline constexpr bool is_alnum_plus(char c) noexcept;

/**
* @details An ASCII hex digit is an ASCII upper hex digit or ASCII lower hex
* digit. An ASCII upper hex digit is an ASCII digit or a code point in the
* range U+0041 (A) to U+0046 (F), inclusive. An ASCII lower hex digit is an
* ASCII digit or a code point in the range U+0061 (a) to U+0066 (f), inclusive.
*/
ada_really_inline constexpr bool is_ascii_hex_digit(const char c) noexcept;
ada_really_inline constexpr bool is_ascii_hex_digit(char c) noexcept;

/**
* Checks if the input is a C0 control or space character.
Expand All @@ -125,33 +124,33 @@ ada_really_inline constexpr bool is_ascii_hex_digit(const char c) noexcept;
* A C0 control is a code point in the range U+0000 NULL to U+001F INFORMATION
* SEPARATOR ONE, inclusive.
*/
ada_really_inline constexpr bool is_c0_control_or_space(const char c) noexcept;
ada_really_inline constexpr bool is_c0_control_or_space(char c) noexcept;

/**
* Checks if the input is a ASCII tab or newline character.
*
* @details An ASCII tab or newline is U+0009 TAB, U+000A LF, or U+000D CR.
*/
ada_really_inline constexpr bool is_ascii_tab_or_newline(const char c) noexcept;
ada_really_inline constexpr bool is_ascii_tab_or_newline(char c) noexcept;

/**
* @details A double-dot path segment must be ".." or an ASCII case-insensitive
* match for ".%2e", "%2e.", or "%2e%2e".
*/
ada_really_inline ada_constexpr bool is_double_dot_path_segment(
const std::string_view input) noexcept;
std::string_view input) noexcept;

/**
* @details A single-dot path segment must be "." or an ASCII case-insensitive
* match for "%2e".
*/
ada_really_inline constexpr bool is_single_dot_path_segment(
const std::string_view input) noexcept;
std::string_view input) noexcept;

/**
* @details ipv4 character might contain 0-9 or a-f character ranges.
*/
ada_really_inline constexpr bool is_lowercase_hex(const char c) noexcept;
ada_really_inline constexpr bool is_lowercase_hex(char c) noexcept;

/**
* @details Convert hex to binary. Caller is responsible to ensure that
Expand All @@ -167,20 +166,20 @@ ada_really_inline unsigned constexpr convert_hex_to_binary(char c) noexcept;
* @see https://github.com/nodejs/node/blob/main/src/node_url.cc#L245
* @see https://encoding.spec.whatwg.org/#utf-8-decode-without-bom
*/
std::string percent_decode(const std::string_view input, size_t first_percent);
std::string percent_decode(std::string_view input, size_t first_percent);

/**
* Returns a percent-encoding string whether percent encoding was needed or not.
* @see https://github.com/nodejs/node/blob/main/src/node_url.cc#L226
*/
std::string percent_encode(const std::string_view input,
std::string percent_encode(std::string_view input,
const uint8_t character_set[]);
/**
* Returns a percent-encoded string version of input, while starting the percent
* encoding at the provided index.
* @see https://github.com/nodejs/node/blob/main/src/node_url.cc#L226
*/
std::string percent_encode(const std::string_view input,
std::string percent_encode(std::string_view input,
const uint8_t character_set[], size_t index);
/**
* Returns true if percent encoding was needed, in which case, we store
Expand All @@ -190,13 +189,13 @@ std::string percent_encode(const std::string_view input,
* @see https://github.com/nodejs/node/blob/main/src/node_url.cc#L226
*/
template <bool append>
bool percent_encode(const std::string_view input, const uint8_t character_set[],
bool percent_encode(std::string_view input, const uint8_t character_set[],
std::string& out);
/**
* Returns the index at which percent encoding should start, or (equivalently),
* the length of the prefix that does not require percent encoding.
*/
ada_really_inline size_t percent_encode_index(const std::string_view input,
ada_really_inline size_t percent_encode_index(std::string_view input,
const uint8_t character_set[]);
/**
* Lowers the string in-place, assuming that the content is ASCII.
Expand Down
4 changes: 3 additions & 1 deletion include/ada/url-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ inline std::ostream &operator<<(std::ostream &out, const ada::url &u) {
return out << u.to_string();
}

size_t url::get_pathname_length() const noexcept { return path.size(); }
[[nodiscard]] size_t url::get_pathname_length() const noexcept {
return path.size();
}

[[nodiscard]] ada_really_inline ada::url_components url::get_components()
const noexcept {
Expand Down
48 changes: 25 additions & 23 deletions include/ada/url.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct url : url_base {
url(url &&u) noexcept = default;
url &operator=(url &&u) noexcept = default;
url &operator=(const url &u) = default;
~url() = default;
~url() override = default;

/**
* @private
Expand Down Expand Up @@ -102,7 +102,7 @@ struct url : url_base {
/**
* Returns a JSON string representation of this URL.
*/
std::string to_string() const override;
[[nodiscard]] std::string to_string() const override;

/**
* @see https://url.spec.whatwg.org/#dom-url-href
Expand Down Expand Up @@ -149,15 +149,15 @@ struct url : url_base {
* @return a newly allocated string.
* @see https://url.spec.whatwg.org/#dom-url-pathname
*/
[[nodiscard]] const std::string_view get_pathname() const noexcept;
[[nodiscard]] std::string_view get_pathname() const noexcept;

/**
* Compute the pathname length in bytes without instantiating a view or a
* string.
* @return size of the pathname in bytes
* @see https://url.spec.whatwg.org/#dom-url-pathname
*/
ada_really_inline size_t get_pathname_length() const noexcept;
[[nodiscard]] ada_really_inline size_t get_pathname_length() const noexcept;

/**
* Return U+003F (?), followed by this's URL's query.
Expand All @@ -177,60 +177,60 @@ struct url : url_base {
* @return Returns true on successful operation.
* @see https://url.spec.whatwg.org/#dom-url-username
*/
bool set_username(const std::string_view input);
bool set_username(std::string_view input);

/**
* @return Returns true on success.
* @see https://url.spec.whatwg.org/#dom-url-password
*/
bool set_password(const std::string_view input);
bool set_password(std::string_view input);

/**
* @return Returns true on success.
* @see https://url.spec.whatwg.org/#dom-url-port
*/
bool set_port(const std::string_view input);
bool set_port(std::string_view input);

/**
* This function always succeeds.
* @see https://url.spec.whatwg.org/#dom-url-hash
*/
void set_hash(const std::string_view input);
void set_hash(std::string_view input);

/**
* This function always succeeds.
* @see https://url.spec.whatwg.org/#dom-url-search
*/
void set_search(const std::string_view input);
void set_search(std::string_view input);

/**
* @return Returns true on success.
* @see https://url.spec.whatwg.org/#dom-url-search
*/
bool set_pathname(const std::string_view input);
bool set_pathname(std::string_view input);

/**
* @return Returns true on success.
* @see https://url.spec.whatwg.org/#dom-url-host
*/
bool set_host(const std::string_view input);
bool set_host(std::string_view input);

/**
* @return Returns true on success.
* @see https://url.spec.whatwg.org/#dom-url-hostname
*/
bool set_hostname(const std::string_view input);
bool set_hostname(std::string_view input);

/**
* @return Returns true on success.
* @see https://url.spec.whatwg.org/#dom-url-protocol
*/
bool set_protocol(const std::string_view input);
bool set_protocol(std::string_view input);

/**
* @see https://url.spec.whatwg.org/#dom-url-href
*/
bool set_href(const std::string_view input);
bool set_href(std::string_view input);

/**
* The password getter steps are to return this's URL's password.
Expand Down Expand Up @@ -301,9 +301,9 @@ struct url : url_base {
inline void update_base_search(std::string_view input,
const uint8_t query_percent_encode_set[]);
inline void update_base_search(std::optional<std::string> input);
inline void update_base_pathname(const std::string_view input);
inline void update_base_username(const std::string_view input);
inline void update_base_password(const std::string_view input);
inline void update_base_pathname(std::string_view input);
inline void update_base_username(std::string_view input);
inline void update_base_password(std::string_view input);
inline void update_base_port(std::optional<uint16_t> input);

/**
Expand Down Expand Up @@ -349,9 +349,12 @@ struct url : url_base {
*/
[[nodiscard]] inline bool cannot_have_credentials_or_port() const;

ada_really_inline size_t
parse_port(std::string_view view,
bool check_trailing_content = false) noexcept override;
ada_really_inline size_t parse_port(
std::string_view view, bool check_trailing_content) noexcept override;

ada_really_inline size_t parse_port(std::string_view view) noexcept override {
return this->parse_port(view, false);
}

/**
* Take the scheme from another URL. The scheme string is copied from the
Expand All @@ -370,8 +373,7 @@ struct url : url_base {
[[nodiscard]] ada_really_inline bool parse_host(std::string_view input);

template <bool has_state_override = false>
[[nodiscard]] ada_really_inline bool parse_scheme(
const std::string_view input);
[[nodiscard]] ada_really_inline bool parse_scheme(std::string_view input);

inline void clear_pathname() override;
inline void clear_search() override;
Expand All @@ -387,7 +389,7 @@ struct url : url_base {
*
* @see https://url.spec.whatwg.org/
*/
ada_really_inline void parse_path(const std::string_view input);
ada_really_inline void parse_path(std::string_view input);

/**
* Set the scheme for this URL. The provided scheme should be a valid
Expand Down
9 changes: 5 additions & 4 deletions include/ada/url_aggregator-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ inline void url_aggregator::update_base_hostname(const std::string_view input) {
ADA_ASSERT_TRUE(validate());
}

ada_really_inline uint32_t
[[nodiscard]] ada_really_inline uint32_t
url_aggregator::get_pathname_length() const noexcept {
ada_log("url_aggregator::get_pathname_length");
uint32_t ending_index = uint32_t(buffer.size());
Expand Down Expand Up @@ -587,7 +587,7 @@ inline void url_aggregator::clear_port() {
ADA_ASSERT_TRUE(validate());
}

inline uint32_t url_aggregator::retrieve_base_port() const {
[[nodiscard]] inline uint32_t url_aggregator::retrieve_base_port() const {
ada_log("url_aggregator::retrieve_base_port");
return components.port;
}
Expand Down Expand Up @@ -812,7 +812,7 @@ inline bool url_aggregator::has_port() const noexcept {
return has_hostname() && components.pathname_start != components.host_end;
}

inline bool url_aggregator::has_dash_dot() const noexcept {
[[nodiscard]] inline bool url_aggregator::has_dash_dot() const noexcept {
// If url's host is null, url does not have an opaque path, url's path's size
// is greater than 1, and url's path[0] is the empty string, then append
// U+002F (/) followed by U+002E (.) to output.
Expand All @@ -833,7 +833,8 @@ inline bool url_aggregator::has_dash_dot() const noexcept {
components.pathname_start + 1 < buffer.size();
}

inline std::string_view url_aggregator::get_href() const noexcept {
[[nodiscard]] inline std::string_view url_aggregator::get_href()
const noexcept {
ada_log("url_aggregator::get_href");
return buffer;
}
Expand Down
Loading