| 16171 | } |
| 16172 | |
| 16173 | tl::expected<std::string, errors> canonicalize_port( |
| 16174 | std::string_view port_value) { |
| 16175 | // If portValue is the empty string, return portValue. |
| 16176 | if (port_value.empty()) [[unlikely]] { |
| 16177 | return ""; |
| 16178 | } |
| 16179 | // Let dummyURL be a new URL record. |
| 16180 | // If protocolValue was given, then set dummyURL's scheme to protocolValue. |
| 16181 | // Let parseResult be the result of running basic URL parser given portValue |
| 16182 | // with dummyURL as url and port state as state override. |
| 16183 | auto url = ada::parse<url_aggregator>("fake://dummy.test", nullptr); |
| 16184 | ADA_ASSERT_TRUE(url); |
| 16185 | if (url->set_port(port_value)) { |
| 16186 | // Return dummyURL's port, serialized, or empty string if it is null. |
| 16187 | return std::string(url->get_port()); |
| 16188 | } |
| 16189 | // If parseResult is failure, then throw a TypeError. |
| 16190 | return tl::unexpected(errors::type_error); |
| 16191 | } |
| 16192 | |
| 16193 | tl::expected<std::string, errors> canonicalize_port_with_protocol( |
| 16194 | std::string_view port_value, std::string_view protocol) { |
nothing calls this directly
no test coverage detected