refactor: share Uri/Url decoded-path projection and builder gates#48
Merged
Conversation
37d0b91 to
7e0814c
Compare
…lder gates
Two verbatim duplications between the deliberately-separate Uri and Url
profiles, factored without coupling the two:
- The decoded-path-segments projection (a `when` over the shared UrlPath that
percent-decodes each segment) was byte-identical in
Uri.computeDecodedPathSegments and Url.pathSegments. Move it to a
`decodedSegments` helper in UrlPath, alongside the existing shared
fileNameOf / toUriPathString / appendPathSegments projections, following the
same decode-lambda convention that keeps UrlPath percent-codec-free. Each
caller's caching is unchanged (Uri still memoizes via `by lazy`, Url still
recomputes per access).
- Each builder stated its composability rules twice — throwing `require`s for
build() and a boolean chain for buildOrNull() — so a rule change had to be
mirrored by hand or the two would silently diverge. Replace each with one
ordered, private, per-profile `composabilityError(): String?`; build()
throws IllegalArgumentException with the first failure's message (identical
to the prior `require`), buildOrNull() returns null when it is non-null. The
two forms were verified exactly equivalent beforehand.
Per-profile throughout: no shared supertype, no cross-profile coupling. Pure
refactor, public API unchanged.
1b431d8 to
fc6fd17
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
Two verbatim duplications between the deliberately-separate
Uri(RFC 3986) andUrl(WHATWG) profiles.whenover the sharedUrlPaththat percent-decodes each segment — was byte-identical inUri.computeDecodedPathSegmentsandUrl.pathSegments.requires forbuild()and a boolean&&chain forbuildOrNull(). A rule change had to be mirrored by hand or the two would silently diverge.Change
decodedSegmentshelper inUrlPath, beside the existing sharedfileNameOf/toUriPathString/appendPathSegmentsprojections, following the same decode-lambda convention that keepsUrlPathpercent-codec-free. Each caller's caching is preserved (Urimemoizes viaby lazy;Urlrecomputes per access — a pre-existing, out-of-scope asymmetry).composabilityError(): String?.build()throwsIllegalArgumentExceptionwith the first failure's message (identical to the priorrequire);buildOrNull()returns null when it's non-null. The two prior forms were verified exactly equivalent first — no pre-existing drift.Safety
Per-profile throughout — no shared supertype, no cross-profile coupling (the two-profile design is intentional). Pure refactor: exception types, messages, and check order are unchanged;
buildOrNull()returns null in exactly the same cases. Public API unchanged (apiCheckpasses with noapiDump). Verified on the JVM gate + a Kotlin/NativemacosArm64compile.Stacked on #47.