Skip to content

Commit

Permalink
fix port setting caused by url parser bug
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jan 5, 2025
1 parent ce29698 commit e958292
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/url_pattern_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,10 @@ tl::expected<std::string, errors> canonicalize_port_with_protocol(
// with dummyURL as url and port state as state override.
auto url = ada::parse<url_aggregator>(std::string(protocol) + "://dummy.test",
nullptr);
if (url && url->set_port(port_value)) {
// TODO: Remove has_port() check.
// This is actually a bug with url parser where set_port() returns true for
// "invalid80" port value.
if (url && url->set_port(port_value) && url->has_port()) {
// Return dummyURL’s port, serialized, or empty string if it is null.
return std::string(url->get_port());
}
Expand Down

0 comments on commit e958292

Please sign in to comment.