Repository navigation
Keep host type in sync when replacing or inheriting hosts - #1377
Conversation
Signed-off-by: Perfloop Agent <[email protected]>
Signed-off-by: Perfloop Agent <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1377 +/- ##
==========================================
+ Coverage 65.34% 65.41% +0.06%
==========================================
Files 43 43
Lines 8926 8937 +11
Branches 3986 3986
==========================================
+ Hits 5833 5846 +13
Misses 799 799
+ Partials 2294 2292 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| } | ||
|
|
||
| inline void url_aggregator::update_base_hostname(const std::string_view input) { | ||
| host_type = DEFAULT; |
There was a problem hiding this comment.
Nit: url_aggregator::update_base_hostname now resets host_type, but its ada::url counterpart (include/ada/url-inl.h:131, inline void url::update_base_hostname(std::string_view input) { host = input; }) does not. It's harmless today because the only caller (src/parser.cpp, empty host in the HOST state) runs while host_type is still DEFAULT, but a future caller on an ada::url holding an IPv4/IPv6 host would leave host_type stale — the same kind of mismatch this PR fixes.
Adding host_type = DEFAULT; to url::update_base_hostname would close it.
There was a problem hiding this comment.
I’ll add the same DEFAULT reset to url::update_base_hostname, keeping the existing tests and checking its empty-host parser path along with host mutation and relative resolution.
There was a problem hiding this comment.
Added host_type = DEFAULT; before the host assignment in url::update_base_hostname, matching the aggregator helper. The existing tests are unchanged; all 447 CTest tests pass, as do formatting and static analysis.
Signed-off-by: Perfloop Agent <[email protected]>
set_hostandset_hostnamecan replace an IP host while leaving its classification as IPv4 or IPv6; relative resolution can inherit an IP host but reportDEFAULT. This change keepshost_typein sync with the host in bothada::urlandada::url_aggregator, including callers ofada_get_host_typein the C API.For example, setting the host of
http://127.0.0.1/pathtoexample.comproduceshttp://example.com/pathwhile still reportingIPV4. With this change,host_typereportsDEFAULT, matching a fresh parse of the resulting URL after either setter.The setters reset
host_typetoDEFAULTwhen a domain or opaque host is accepted, and when they clear the host. File URLs also getDEFAULTwhenlocalhostis normalized to an empty host. Setting an IPv4 or IPv6 host still leaveshost_typeasIPV4orIPV6. Failed setters leave the existinghost_typeuntouched.Relative resolution now copies the classification together with the base host at all four state-machine copy sites.
tests/basic_tests.cppcovers both setters and representations, including filelocalhost, rejected mutations, and relative resolution with IPv4/IPv6 HTTP and file bases. Both typed tests fail on main before this change for each URL type.CTest passed all 447 tests, with 0 failures and 0 skipped.
cc @anonrig @lemire
Case and evidence
Made by Perfloop. Human sponsor: Tomás Senart.