17template <
typename out_iter>
21 "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f";
26 }
else if (
c ==
'"') {
29 }
else if (
c <= 0x1f) {
47 return "Scheme Start";
57 return "Relative Scheme";
59 return "Relative Slash";
67 return "Path or Authority";
69 return "Special Authority Ignore Slashes";
71 return "Special Authority Slashes";
73 return "Special Relative or Authority";
85 return "unknown state";
90 std::string_view&
input)
noexcept {
97 std::string_view hash =
input;
108 path.find(
'/', 1) == std::string_view::npos && !path.empty()) {
110 helpers::substring(path, 1))) {
131 path.find(
'/', 1) == std::string_view::npos && !path.empty()) {
133 helpers::substring(path, 1))) {
141 if (
slash_loc != std::string_view::npos) {
142 path.remove_suffix(path.size() -
slash_loc);
153 std::erase_if(
input, ada::unicode::is_ascii_tab_or_newline);
161 return input.substr(pos);
172#ifdef ADA_REGULAR_VISUAL_STUDIO
203 _mm_setr_epi8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
204 0x01, 0x04, 0x04, 0x00, 0x00, 0x03);
206 _mm_setr_epi8(0x00, 0x00, 0x02, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
210 for (;
i + 15 <
view.size();
i += 16) {
225 if (
i <
view.size()) {
247#ifndef ada_make_uint8x16_t
248#define ada_make_uint8x16_t(x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, \
249 x13, x14, x15, x16) \
251 static uint8_t array[16] = {x1, x2, x3, x4, x5, x6, x7, x8, \
252 x9, x10, x11, x12, x13, x14, x15, x16}; \
253 return vld1q_u8(array); \
272 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80);
284 0x00, 0x01, 0x04, 0x04, 0x00, 0x00, 0x03);
287 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
290 for (;
i + 15 <
view.size();
i += 16) {
302 if (
i <
view.size()) {
337 for (;
i + 15 <
view.size();
i += 16) {
351 if (
i <
view.size()) {
389 for (;
i + 15 <
view.size();
i += 16) {
403 if (
i <
view.size()) {
428 0xF, 0, 0, 0, 0, 0,
'[',
'\\', 0, 0, 0,
'/', 0, 0,
':',
'?'
460 std::array<uint8_t, 256>
result{};
461 for (
int i : {
':',
'/',
'[',
'\\',
'?'}) {
470 for (
auto pos =
str.begin(); pos !=
str.end(); ++pos) {
503 _mm_setr_epi8(0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
504 0x01, 0x04, 0x00, 0x00, 0x00, 0x03);
506 _mm_setr_epi8(0x00, 0x00, 0x02, 0x01, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
507 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
511 for (;
i + 15 <
view.size();
i += 16) {
527 if (
i <
view.size()) {
561 0x02, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80);
573 0x00, 0x01, 0x04, 0x00, 0x00, 0x00, 0x03);
576 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
579 for (;
i + 15 <
view.size();
i += 16) {
591 if (
i <
view.size()) {
625 for (;
i + 15 <
view.size();
i += 16) {
637 if (
i <
view.size()) {
672 for (;
i + 15 <
view.size();
i += 16) {
684 if (
i <
view.size()) {
721 std::array<uint8_t, 256>
result{};
722 for (
int i : {
':',
'/',
'?',
'['}) {
731 for (
auto pos =
str.begin(); pos !=
str.end(); ++pos) {
741 const bool is_special, std::string_view&
view)
noexcept {
781 if (
location == std::string_view::npos) {
802 if (
location == std::string_view::npos) {
820void trim_c0_whitespace(std::string_view&
input)
noexcept {
821 while (!
input.empty() &&
822 ada::unicode::is_c0_control_or_space(
input.front())) {
823 input.remove_prefix(1);
825 while (!
input.empty() && ada::unicode::is_c0_control_or_space(
input.back())) {
826 input.remove_suffix(1);
859 if (
input[0] !=
'.') {
864 if (
slashdot == std::string_view::npos) {
891 ada_log(
"parse_prepared_path fast");
910 if (path.back() ==
'/') {
915 path.resize(path.rfind(
'/') + 1);
946 ?
input.find_first_of(
"/\\")
949 if (
location != std::string_view::npos) {
957 ada::unicode::percent_encode<false>(
961 if (unicode::is_double_dot_path_segment(
path_buffer)) {
962 helpers::shorten_path(path, type);
963 if (
location == std::string_view::npos) {
966 }
else if (unicode::is_single_dot_path_segment(
path_buffer) &&
967 (
location == std::string_view::npos)) {
971 else if (!unicode::is_single_dot_path_segment(
path_buffer)) {
988 if (
location == std::string_view::npos) {
995bool overlaps(std::string_view
input1,
const std::string&
input2)
noexcept {
996 ada_log(
"helpers::overlaps check if string_view '",
input1,
"' [",
997 input1.size(),
" bytes] is part of string '",
input2,
"' [",
998 input2.size(),
" bytes]");
1003template <
class url_type>
1005 ada_log(
"helpers::strip_trailing_spaces_from_opaque_path");
1006 if (!url.has_opaque_path)
return;
1007 if (url.has_hash())
return;
1008 if (url.has_search())
return;
1010 auto path = std::string(url.get_pathname());
1011 while (!path.empty() && path.back() ==
' ') {
1012 path.resize(path.size() - 1);
1014 url.update_base_pathname(path);
1020 std::array<uint8_t, 256>
result{};
1021 for (
uint8_t i : {
'@',
'/',
'\\',
'?'}) {
1028find_authority_delimiter_special(std::string_view
view)
noexcept {
1031 for (
auto pos =
view.begin(); pos !=
view.end(); ++pos) {
1033 return pos -
view.begin();
1041 std::array<uint8_t, 256>
result{};
1042 for (
uint8_t i : {
'@',
'/',
'?'}) {
1049find_authority_delimiter(std::string_view
view)
noexcept {
1052 for (
auto pos =
view.begin(); pos !=
view.end(); ++pos) {
1054 return pos -
view.begin();
1066#undef ada_make_uint8x16_t
Definitions for URL specific checkers used within Ada.
Cross-platform compiler macros and common definitions.
#define ADA_ASSERT_TRUE(COND)
#define ada_really_inline
Definitions for helper functions used within Ada.
constexpr uint8_t PATH_PERCENT_ENCODE[32]
constexpr bool is_normalized_windows_drive_letter(std::string_view input) noexcept
constexpr bool is_windows_drive_letter(std::string_view input) noexcept
Includes the definitions for helper functions.
ada_really_inline size_t find_next_host_delimiter(std::string_view view, size_t location) noexcept
static constexpr std::array< uint8_t, 256 > authority_delimiter_special
static constexpr std::array< uint8_t, 256 > host_delimiters
ada_really_inline size_t find_next_host_delimiter_special(std::string_view view, size_t location) noexcept
ada_unused std::string get_state(ada::state s)
static constexpr std::array< uint8_t, 256 > authority_delimiter
static constexpr std::array< uint8_t, 256 > special_host_delimiters
ada_really_inline int trailing_zeroes(uint32_t input_num) noexcept
type
Enumeration of URL scheme types.
state
States in the URL parsing state machine.
@ SPECIAL_RELATIVE_OR_AUTHORITY
@ SPECIAL_AUTHORITY_SLASHES
@ SPECIAL_AUTHORITY_IGNORE_SLASHES
tl::expected< result_type, ada::errors > result
ada_warn_unused std::string_view to_string(encoding_type type)
ada_warn_unused ada::result< result_type > parse(std::string_view input, const result_type *base_url=nullptr)
URL scheme type definitions and utilities.
URL parser state machine states.