refactor: consolidate host/authority/path serialization#47
Merged
Conversation
5f30ed1 to
4037494
Compare
Serialization logic was reimplemented in several places instead of delegating
to the canonical renderers:
- parser/Resolver held a byte-for-byte copy of host/HostSerialization's
serializeHost (the host `when`, the zone-id suffix, the "%25" constant) —
a latent drift bug in the resolution path's re-serialization. Deleted; it
now calls serializeHost.
- Url.encodedPath and Url.authority re-implemented Serializer's URL-path and
authority serialization, including the non-obvious leading-"/." path guard.
Promoted Serializer's helpers to internal top-level functions
(serializeUrlPath, serializeAuthority) and delegated Url to them; Serializer
still uses them itself.
- Removed the redundant internal Host.serialize() extension — a synonym for
the public Host.asText() with an identical body — and routed its callers to
asText(). This drops one tautological Ipv6 test that only asserted the two
synonyms agree; asText() stays covered by the host validation / ipv4 / ipv6
suites and the coverage floor still holds.
Two duplications are left in place on purpose. Uri.reconstructAuthority keeps
its own assembly: its nullable-userInfo empty->null distinction can't be
expressed by the string-only shared helper. Resolver's authority assembly is
also left duplicated — consolidating it would add a parser->serialize import
and form a package cycle with the existing serialize->parser edge, which four
trivial lines don't justify.
Pure refactor: no behavior change, public API unchanged.
37d0b91 to
7e0814c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Host / authority / URL-path serialization was reimplemented in several places instead of delegating to the canonical renderers.
parser/Resolverheld a byte-for-byte copy ofhost/HostSerialization'sserializeHost(the hostwhen, the zone-id suffix, the"%25"constant) — a latent drift bug: change host serialization and the resolution path silently diverges.Url.encodedPathandUrl.authorityre-implementedSerializer's URL-path and authority serialization, including the non-obvious leading-/.path guard.Host.serialize()extension duplicated the publicHost.asText()(identical body).Change
Resolvernow callsserializeHost; its copy is deleted.Serializer's path/authority helpers tointernaltop-levelserializeUrlPath/serializeAuthority;Urldelegates to them andSerializerkeeps using them.Host.serialize()synonym and routed callers toasText(). This drops one tautologicalIpv6Testthat only assertedserialize() == asText();asText()remains covered by the host-validation / ipv4 / ipv6 suites and the Kover floor still holds.Left duplicated on purpose
Uri.reconstructAuthority— its nullable-userInfoempty→null distinction can't be expressed by the string-only shared helper.Resolver's authority assembly — the logic is identical to the shared helper, but importingserializeintoparserwould form a package cycle with the existingserialize→parseredge (UriNormalizer→Resolver.removeDotSegments). Four trivial lines aren't worth a cycle.Safety
Pure refactor — no behavior change, public API unchanged (
apiCheckpasses with noapiDump). Verified on the JVM gate +koverVerify+ a Kotlin/NativemacosArm64compile. Net −53 lines.Stacked on #46.