| 13913 | namespace ada { |
| 13914 | template <bool has_state_override> |
| 13915 | [[nodiscard]] ada_really_inline bool url_aggregator::parse_scheme_with_colon( |
| 13916 | const std::string_view input_with_colon) { |
| 13917 | ada_log("url_aggregator::parse_scheme_with_colon ", input_with_colon); |
| 13918 | ADA_ASSERT_TRUE(validate()); |
| 13919 | ADA_ASSERT_TRUE(!helpers::overlaps(input_with_colon, buffer)); |
| 13920 | std::string_view input{input_with_colon}; |
| 13921 | input.remove_suffix(1); |
| 13922 | auto parsed_type = ada::scheme::get_scheme_type(input); |
| 13923 | const bool is_input_special = (parsed_type != ada::scheme::NOT_SPECIAL); |
| 13924 | /** |
| 13925 | * In the common case, we will immediately recognize a special scheme (e.g., |
| 13926 | *http, https), in which case, we can go really fast. |
| 13927 | **/ |
| 13928 | if (is_input_special) { // fast path!!! |
| 13929 | if constexpr (has_state_override) { |
| 13930 | // If url's scheme is not a special scheme and buffer is a special scheme, |
| 13931 | // then return. |
| 13932 | if (is_special() != is_input_special) { |
| 13933 | return false; |
| 13934 | } |
| 13935 | |
| 13936 | // If url includes credentials or has a non-null port, and buffer is |
| 13937 | // "file", then return. |
| 13938 | if ((has_credentials() || components.port != url_components::omitted) && |
| 13939 | parsed_type == ada::scheme::type::FILE) { |
| 13940 | return false; |
| 13941 | } |
| 13942 | |
| 13943 | // If url's scheme is "file" and its host is an empty host, then return. |
| 13944 | // An empty host is the empty string. |
| 13945 | if (type == ada::scheme::type::FILE && |
| 13946 | components.host_start == components.host_end) { |
| 13947 | return false; |
| 13948 | } |
| 13949 | } |
| 13950 | |
| 13951 | type = parsed_type; |
| 13952 | set_scheme_from_view_with_colon(input_with_colon); |
| 13953 | |
| 13954 | if constexpr (has_state_override) { |
| 13955 | // This is uncommon. |
| 13956 | uint16_t urls_scheme_port = get_special_port(); |
| 13957 | |
| 13958 | // If url's port is url's scheme's default port, then set url's port to |
| 13959 | // null. |
| 13960 | if (components.port == urls_scheme_port) { |
| 13961 | clear_port(); |
| 13962 | } |
| 13963 | } |
| 13964 | } else { // slow path |
| 13965 | std::string _buffer(input); |
| 13966 | // Next function is only valid if the input is ASCII and returns false |
| 13967 | // otherwise, but it seems that we always have ascii content so we do not |
| 13968 | // need to check the return value. |
| 13969 | unicode::to_lower_ascii(_buffer.data(), _buffer.size()); |
| 13970 | |
| 13971 | if constexpr (has_state_override) { |
| 13972 | // If url's scheme is a special scheme and buffer is not a special scheme, |
no test coverage detected