Noted while doing #95 (see PR #111), which collapsed the query-value encoders. The path side has the
same shape and was deliberately left alone to keep that PR a single concern.
What's there
APIClientTransport.swift provides:
func pathSegment(_ segment: String) -> String {
segment.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? segment
}
but roughly a dozen call sites still inline the same expression:
let encoded = id.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? id
Why this is lower priority than #95 was
These are correct as written. Unlike the query-value case, there is no latent bug here —
.urlPathAllowed is the right set for a path segment, and the inline form produces exactly what
pathSegment(_:) would. This is consistency and discoverability, not correctness.
The reason it is worth doing at all: with two near-identical idioms in the file, the next person
copying one has a coin-flip chance of reaching for the wrong one, and picking .urlQueryAllowed for
a query value is precisely the bug #95 just spent a PR removing. #111 put queryValue(_:) directly
beside pathSegment(_:) with a comment saying they are not interchangeable; converting the
stragglers makes the file self-consistent so the comment is reinforced rather than contradicted.
Build this
Acceptance criteria
Files: Services/APIClient.swift and the APIClient+*.swift extensions.
Noted while doing #95 (see PR #111), which collapsed the query-value encoders. The path side has the
same shape and was deliberately left alone to keep that PR a single concern.
What's there
APIClientTransport.swiftprovides:but roughly a dozen call sites still inline the same expression:
Why this is lower priority than #95 was
These are correct as written. Unlike the query-value case, there is no latent bug here —
.urlPathAllowedis the right set for a path segment, and the inline form produces exactly whatpathSegment(_:)would. This is consistency and discoverability, not correctness.The reason it is worth doing at all: with two near-identical idioms in the file, the next person
copying one has a coin-flip chance of reaching for the wrong one, and picking
.urlQueryAllowedfora query value is precisely the bug #95 just spent a PR removing. #111 put
queryValue(_:)directlybeside
pathSegment(_:)with a comment saying they are not interchangeable; converting thestragglers makes the file self-consistent so the comment is reinforced rather than contradicted.
Build this
.urlPathAllowedencodings of a path segment withpathSegment(_:).path or something with intentional slashes,
pathSegment(_:)is the wrong tool and it shouldkeep doing what it does, with a comment saying why.
that would mean the two forms were not equivalent after all.
Acceptance criteria
.urlPathAllowedpath-segment encoding remains, or each survivor has a one-linecomment explaining why it is not using the helper.
Files:
Services/APIClient.swiftand theAPIClient+*.swiftextensions.