diff --git a/seafire/protocol/rfc7230/host.cxx b/seafire/protocol/rfc7230/host.cxx index 9ca48a4..b77f980 100644 --- a/seafire/protocol/rfc7230/host.cxx +++ b/seafire/protocol/rfc7230/host.cxx @@ -33,13 +33,13 @@ namespace seafire::protocol::rfc7230 host_t:: try_parse(std::vector const& strings, std::error_code&) { - std::string host_part; - std::optional opt_port_part; - if (auto it = strings.rbegin(); it != strings.rend()) { auto first = it->begin(); auto last = it->end(); + std::string host_part; + std::optional opt_port_part; + auto try_parse_host = [&](auto init) { auto c = init; @@ -73,12 +73,12 @@ namespace seafire::protocol::rfc7230 first = try_parse_host(first); first = try_parse_port(first); - if (first != last) { - return std::nullopt; + if (first == last) { + return {{host_part, opt_port_part}}; } } - return {{host_part, opt_port_part}}; + return std::nullopt; } std::string