Repository navigation
test(router): pin a catch-all tail segment ending in } as literal - #193
Conversation
A tail segment like `id}` reaches `toSegment`, whose param check needs a
leading `{` as well as a trailing `}`; no test failed when the leading
check was dropped, which made `id}` a param named `d`.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VVaw7Sutbw6xMTMyDFeNfw
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Pin catch-all tail ending in
}as literal — adds/f/{+p}/id}to the literal-segment suite plus assertions that/f/1/id}matches ({ p: '1' }) and/f/1/iddoes not.
I verified the PR's central claim: with the leading-{ half of toSegment's check removed, id} becomes param d and the new assertion fails (params.d = 'id}'). The full router suite passes as-is. Test-only, no production code touched.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

Requested by dinwwwh · project thread
What
This is a test-only change. The literal-text test in
router.test.tsnow adds/f/{+p}/id}and checks two requests:/f/1/id}matches it, with{ p: '1' }./f/1/idmatches nothing.Why
Since #186, the tree build calls
toSegmentonly for parts that start with{. A catch-all's tail segments still go throughtoSegmentwhatever they start with, and so doparse's callers (createPrefixMatcherand the two-catch-all check inadd). Mutation testing found that dropping the leading-{half oftoSegment's param check failed no test, even with the 73 tests now on main. With that mutant,id}becomes a param namedd, so/f/1/idmatches. The new assertions catch it.Checks
pnpm checkpasses.Generated by Claude Code