fix(http): keep every ? after the first in the query string (CARD-25, GitHub #48) #136

Merged
chrnx merged 1 commits from feature/fprd-001c-query-string-question-marks into develop 2026-10-23 05:47:55 +00:00
Owner

What and why

CARD-25, decision D23, GitHub #48. parseQuery took url.split('?')[1], so a second ? ended the query string: /search?q=what?now gave q: 'what'. RFC 3986 §3.4 allows ? inside a query. The query string is now everything after the first ? and before #, if one is present.

  • src/http/router.ts: parseQuery uses indexOf('?') + slice, stopping at #. The fast return for URLs without a query is kept, and so is its measurement note. The comment that deferred this behaviour question is removed (the card asks for that).
  • Path extraction is unchanged; it already split on the first ?.
  • CHANGELOG.md: ### Changed entry.

Tests

test/query-string.test.ts covers T1–T4 through parseQuery directly, through app.fetch and through the Node listener (app.listen), plus a fragment case. Before the fix, 7 of these 13 tests failed (T1 and T2 on every path, plus the fragment case).

Check Result
npm run lint 0 errors (50 existing no-explicit-any warnings, unchanged)
npm run format:check pass
npm run typecheck pass
npm test 93 files, 928 tests passed
npm run build pass
npm run complexity:check every function ≤ 25
npm run test:deno 36 passed, 0 failed
npm run test:bun 26 pass, 0 fail
npm run test:edge PASS (incl. router parity 1158 matcher + 55 app.fetch cases)

Frozen router-parity captures: none changed; no capture covers a second ?.

Rebased on origin/develop after #134 and #135 merged. npm audit --audit-level=moderate passes locally on this branch now, and the Bun close-code tests are fixed on develop. Local checks were re-run after the rebase with the same results.

Unsure about

  • The card's rule says "before #, if present". Node's req.url and a Request URL never carry a fragment, so the # handling only matters for direct callers of the exported parseQuery. I implemented it as the rule says.

Docs follow-up (CARD-12)

  • Request/params guide (@query): note that ? inside a query value is kept (/search?q=what?now → q: 'what?now').
## What and why CARD-25, decision D23, GitHub `#48`. `parseQuery` took `url.split('?')[1]`, so a second `?` ended the query string: `/search?q=what?now` gave `q: 'what'`. RFC 3986 §3.4 allows `?` inside a query. The query string is now everything after the **first** `?` and before `#`, if one is present. - `src/http/router.ts`: `parseQuery` uses `indexOf('?')` + `slice`, stopping at `#`. The fast return for URLs without a query is kept, and so is its measurement note. The comment that deferred this behaviour question is removed (the card asks for that). - Path extraction is unchanged; it already split on the first `?`. - `CHANGELOG.md`: `### Changed` entry. ## Tests `test/query-string.test.ts` covers T1–T4 through `parseQuery` directly, through `app.fetch` and through the Node listener (`app.listen`), plus a fragment case. Before the fix, 7 of these 13 tests failed (T1 and T2 on every path, plus the fragment case). | Check | Result | |---|---| | `npm run lint` | 0 errors (50 existing `no-explicit-any` warnings, unchanged) | | `npm run format:check` | pass | | `npm run typecheck` | pass | | `npm test` | 93 files, 928 tests passed | | `npm run build` | pass | | `npm run complexity:check` | every function ≤ 25 | | `npm run test:deno` | 36 passed, 0 failed | | `npm run test:bun` | 26 pass, 0 fail | | `npm run test:edge` | PASS (incl. router parity 1158 matcher + 55 app.fetch cases) | **Frozen router-parity captures:** none changed; no capture covers a second `?`. **Rebased on `origin/develop` after #134 and #135 merged.** `npm audit --audit-level=moderate` passes locally on this branch now, and the Bun close-code tests are fixed on develop. Local checks were re-run after the rebase with the same results. ## Unsure about - The card's rule says "before `#`, if present". Node's `req.url` and a `Request` URL never carry a fragment, so the `#` handling only matters for direct callers of the exported `parseQuery`. I implemented it as the rule says. ## Docs follow-up (CARD-12) - Request/params guide (`@query`): note that `?` inside a query value is kept (`/search?q=what?now` → `q: 'what?now'`).
chrnx force-pushed feature/fprd-001c-query-string-question-marks from 2dd0d1f8fe to 8d7fe1e35a 2026-10-23 04:55:34 +00:00 Compare
chrnx added 1 commit 2026-10-23 05:02:45 +00:00
fix(http): keep every ? after the first in the query string (CARD-25, GitHub #48)
CI / dco (pull_request) Successful in 4s
CI / runtimes (bun) (pull_request) Successful in 15s
CI / build (pull_request) Successful in 27s
CI / runtimes (deno) (pull_request) Successful in 20s
CI / runtimes (edge) (pull_request) Successful in 14s
8bf54ec168
parseQuery took `url.split('?')[1]`, so a second `?` ended the query
string and `/search?q=what?now` gave `q: 'what'`. RFC 3986 §3.4 allows
`?` inside a query. The query string is now everything after the first
`?` and before `#`, if one is present. The early return for URLs without
a query is kept, and so is its measurement note. The comment that
deferred this behaviour question is removed because the question is now
decided (D23).

Path extraction already split on the first `?` and is unchanged.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
chrnx force-pushed feature/fprd-001c-query-string-question-marks from 8d7fe1e35a to 8bf54ec168 2026-10-23 05:02:45 +00:00 Compare
chrnx merged commit 89ac955072 into develop 2026-10-23 05:47:55 +00:00
chrnx deleted branch feature/fprd-001c-query-string-question-marks 2026-10-23 05:47:56 +00:00
Sign in to join this conversation.