| 16295 | } |
| 16296 | |
| 16297 | tl::expected<std::string, errors> canonicalize_hash(std::string_view input) { |
| 16298 | // If value is the empty string, return value. |
| 16299 | if (input.empty()) [[unlikely]] { |
| 16300 | return ""; |
| 16301 | } |
| 16302 | // Let dummyURL be a new URL record. |
| 16303 | // Set dummyURL's fragment to the empty string. |
| 16304 | // Let parseResult be the result of running basic URL parser given value with |
| 16305 | // dummyURL as url and fragment state as state override. |
| 16306 | auto url = ada::parse<url_aggregator>("fake://dummy.test", nullptr); |
| 16307 | ADA_ASSERT_TRUE(url.has_value()); |
| 16308 | url->set_hash(input); |
| 16309 | // Return dummyURL's fragment. |
| 16310 | if (url->has_hash()) { |
| 16311 | const auto hash = url->get_hash(); |
| 16312 | if (!hash.empty()) { |
| 16313 | return std::string(hash.substr(1)); |
| 16314 | } |
| 16315 | return ""; |
| 16316 | } |
| 16317 | return tl::unexpected(errors::type_error); |
| 16318 | } |
| 16319 | |
| 16320 | tl::expected<std::vector<token>, errors> tokenize(std::string_view input, |
| 16321 | token_policy policy) { |
no test coverage detected