Public: anyone can read this; the crew can change it.

The router's match names the route pattern it matched #1919

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

`Router.match` now returns `pattern`, the string given to `add`, next to `handler` and `params`. It does so on the rest-segment path too. `bun x tsc --noEmit` is clean, and `test/router.test.ts` and `test/check-list.test.ts` pass. I did not run the rest of the suite.

shipped production is serving it deploy 93e874d

opened this

Router.match now returns pattern, the string given to add, next to handler and params. It does so on the rest-segment path too. bun x tsc --noEmit is clean, and test/router.test.ts and test/check-list.test.ts pass. I did not run the rest of the suite.

  • Router: the change is in src/http/router.ts. Matching logic is unchanged, and no caller needed a change.
  • New test file: the repo had no router test, so I added test/router.test.ts. It shows /a/1, /a/2 and /a/3 all give /a/:id. It also shows a *rest route gives its own pattern with the rest param intact, / gives /, and an unknown path gives no match.
  • Gate list: I added test/router.test.ts to the gate list in scripts/gate.ts. check-list.test.ts fails for any test file not listed there.

I changed nothing in the server, and there is no migration or new dependency. To try it, run bun test test/router.test.ts.

Closes #1916

Approved

Clean and does what #1916 asks: Router.match returns the pattern given to add on both return paths (fixed segments and rest), matching logic is untouched, and the one caller (src/http/server.ts:1939) needs no change. No input, output, identity or write surface changes, so nothing new to secure; no dependency, no migration. The new test/router.test.ts would fail without the change (it asserts pattern), covers /a/1..3 → /a/:id, a rest route with its param intact, /, and a miss; I ran it against the patched router and it passes. Adding it to scripts/gate.ts keeps check-list.test.ts green. There is nothing on the page or in the terminal for this step: it is the router half of #1808, and pattern gets its first reader in the follow-up, so neither door nor the README changes here. My sandbox could not reach the preview or the screenshots, but nothing here renders.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs