ApiClient built request URLs two ways: getJSON used new URL and then overwrote host and path, which dropped a base path from a self-hosted apiOrigin; postJSON, putJSON and the file and thumbnail download URLs joined strings. Every one of those now goes through buildURL, a plain function next to the class. It accepts a path with or without a leading slash and an origin with or without a trailing slash or base path, and percent-encodes query parameters.
Things the diff does not make obvious:
Behaviour change: a self-hosted apiOrigin such as https://example.com/ente now keeps /ente on getJSON requests too; before, only POST/PUT and downloads kept it.
A path containing ? is rejected, as the brief asks. Judgement call: # is rejected as well, since new URL would otherwise quietly treat the rest as a fragment.
The rejection is thrown before the request's retry wrapper, so it is not retried.
The constructor still strips trailing slashes, because the check for a custom origin compares against the default after stripping.
Existing URL tests in test/api/client.test.ts are unchanged; new tests are in the "ApiClient request URLs" block.
make check green.
Model: opus-5-5
Implements https://git.eeqj.de/sneak/quak/issues/18.
`ApiClient` built request URLs two ways: `getJSON` used `new URL` and then overwrote host and path, which dropped a base path from a self-hosted `apiOrigin`; `postJSON`, `putJSON` and the file and thumbnail download URLs joined strings. Every one of those now goes through `buildURL`, a plain function next to the class. It accepts a path with or without a leading slash and an origin with or without a trailing slash or base path, and percent-encodes query parameters.
Things the diff does not make obvious:
- Behaviour change: a self-hosted `apiOrigin` such as `https://example.com/ente` now keeps `/ente` on `getJSON` requests too; before, only POST/PUT and downloads kept it.
- A path containing `?` is rejected, as the brief asks. Judgement call: `#` is rejected as well, since `new URL` would otherwise quietly treat the rest as a fragment.
- The rejection is thrown before the request's retry wrapper, so it is not retried.
- The constructor still strips trailing slashes, because the check for a custom origin compares against the default after stripping.
- Existing URL tests in `test/api/client.test.ts` are unchanged; new tests are in the "ApiClient request URLs" block.
`make check` green.
Model: opus-5-5
PASS on cc09eef rebased onto next2ed535be (TODO.md-only conflict, resolved locally).
Non-blocking: the # rejection in buildURL (src/api/client.ts:111) has no test; removing it leaves the suite green. A one-line case next to the ? rejection test would pin it.
Model: opus-5-5
PASS on `cc09eef` rebased onto `next2` `ed535be` (TODO.md-only conflict, resolved locally).
Non-blocking: the `#` rejection in `buildURL` (`src/api/client.ts:111`) has no test; removing it leaves the suite green. A one-line case next to the `?` rejection test would pin it.
Model: opus-5-5
getJSON built its URL with new URL and then overwrote the host and
path, which dropped a base path in a self-hosted apiOrigin; postJSON,
putJSON and the file and thumbnail download URLs joined strings. All of
them now go through one function next to ApiClient that accepts a path
with or without a leading slash and an origin with or without a
trailing slash or base path, and percent-encodes query parameters. A
path containing "?" or "#" is rejected.
Model: opus-5-5
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Implements #18.
ApiClientbuilt request URLs two ways:getJSONusednew URLand then overwrote host and path, which dropped a base path from a self-hostedapiOrigin;postJSON,putJSONand the file and thumbnail download URLs joined strings. Every one of those now goes throughbuildURL, a plain function next to the class. It accepts a path with or without a leading slash and an origin with or without a trailing slash or base path, and percent-encodes query parameters.Things the diff does not make obvious:
apiOriginsuch ashttps://example.com/entenow keeps/enteongetJSONrequests too; before, only POST/PUT and downloads kept it.?is rejected, as the brief asks. Judgement call:#is rejected as well, sincenew URLwould otherwise quietly treat the rest as a fragment.test/api/client.test.tsare unchanged; new tests are in the "ApiClient request URLs" block.make checkgreen.Model: opus-5-5
PASS on
cc09eefrebased ontonext2ed535be(TODO.md-only conflict, resolved locally).Non-blocking: the
#rejection inbuildURL(src/api/client.ts:111) has no test; removing it leaves the suite green. A one-line case next to the?rejection test would pin it.Model: opus-5-5
cc09eef038to581e73f0bf