| 16273 | } |
| 16274 | |
| 16275 | tl::expected<std::string, errors> canonicalize_search(std::string_view input) { |
| 16276 | // If value is the empty string, return value. |
| 16277 | if (input.empty()) [[unlikely]] { |
| 16278 | return ""; |
| 16279 | } |
| 16280 | // Let dummyURL be a new URL record. |
| 16281 | // Set dummyURL's query to the empty string. |
| 16282 | // Let parseResult be the result of running basic URL parser given value with |
| 16283 | // dummyURL as url and query state as state override. |
| 16284 | auto url = ada::parse<url_aggregator>("fake://dummy.test", nullptr); |
| 16285 | ADA_ASSERT_TRUE(url.has_value()); |
| 16286 | url->set_search(input); |
| 16287 | if (url->has_search()) { |
| 16288 | const auto search = url->get_search(); |
| 16289 | if (!search.empty()) { |
| 16290 | return std::string(search.substr(1)); |
| 16291 | } |
| 16292 | return ""; |
| 16293 | } |
| 16294 | return tl::unexpected(errors::type_error); |
| 16295 | } |
| 16296 | |
| 16297 | tl::expected<std::string, errors> canonicalize_hash(std::string_view input) { |
| 16298 | // If value is the empty string, return value. |
no test coverage detected