| 8119 | } |
| 8120 | |
| 8121 | [[nodiscard]] constexpr bool url_aggregator::has_dash_dot() const noexcept { |
| 8122 | // If url's host is null, url does not have an opaque path, url's path's size |
| 8123 | // is greater than 1, and url's path[0] is the empty string, then append |
| 8124 | // U+002F (/) followed by U+002E (.) to output. |
| 8125 | ada_log("url_aggregator::has_dash_dot"); |
| 8126 | #if ADA_DEVELOPMENT_CHECKS |
| 8127 | // If pathname_start and host_end are exactly two characters apart, then we |
| 8128 | // either have a one-digit port such as http://test.com:5?param=1 or else we |
| 8129 | // have a /.: sequence such as "non-spec:/.//". We test that this is the case. |
| 8130 | if (components.pathname_start == components.host_end + 2) { |
| 8131 | ADA_ASSERT_TRUE((buffer[components.host_end] == '/' && |
| 8132 | buffer[components.host_end + 1] == '.') || |
| 8133 | (buffer[components.host_end] == ':' && |
| 8134 | checkers::is_digit(buffer[components.host_end + 1]))); |
| 8135 | } |
| 8136 | if (components.pathname_start == components.host_end + 2 && |
| 8137 | buffer[components.host_end] == '/' && |
| 8138 | buffer[components.host_end + 1] == '.') { |
| 8139 | ADA_ASSERT_TRUE(components.pathname_start + 1 < buffer.size()); |
| 8140 | ADA_ASSERT_TRUE(buffer[components.pathname_start] == '/'); |
| 8141 | ADA_ASSERT_TRUE(buffer[components.pathname_start + 1] == '/'); |
| 8142 | } |
| 8143 | #endif |
| 8144 | // Performance: it should be uncommon for components.pathname_start == |
| 8145 | // components.host_end + 2 to be true. So we put this check first in the |
| 8146 | // sequence. Most times, we do not have an opaque path. Checking for '/.' is |
| 8147 | // more expensive, but should be uncommon. |
| 8148 | return components.pathname_start == components.host_end + 2 && |
| 8149 | !has_opaque_path && buffer[components.host_end] == '/' && |
| 8150 | buffer[components.host_end + 1] == '.'; |
| 8151 | } |
| 8152 | |
| 8153 | [[nodiscard]] constexpr std::string_view url_aggregator::get_href() |
| 8154 | const noexcept ada_lifetime_bound { |