Unify URL construction in ApiClient
#18
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
ApiClientbuilds request URLs two different ways.getJSON(src/api/client.ts:118-123) constructs aURLfrom a base and then overwritesprotocol,hostandpathnamein place. Assigningurl.pathname = pathsilently discardsany query string embedded in
pathand does not percent-encode the value it is given.postJSON(:140) andputJSON(:190) instead concatenate strings:${this.apiOrigin}${path}, with no encoding and no handling of a missing or doubled slash.Two strategies, neither of them obviously correct, is exactly how a path-handling bug gets
introduced later.
Definition of done
ApiClientmethods build URLs through one shared helper.pathwith or without a leading slash, anapiOriginwith orwithout a trailing slash, an
apiOriginthat includes a base path (self-hosted serversbehind a prefix), and query parameters that require percent-encoding.
pathcontaining an embedded query string is either handled correctly or rejected with aclear error — not silently dropped.
test/api/client.test.tsthat assert on request URLs still pass untouched.apiOriginwith a base path.make checkgreen.Not a 1.0.0 blocker
No known failure in production use today; this is hardening against a class of bug rather than
fixing an observed one.