perf(router): index HTTP routes in a radix tree (CARD-07, #109) #128

Merged
chrnx merged 7 commits from feature/fprd-001b-radix-index into develop 2026-10-12 18:54:47 +00:00
Showing only changes of commit 55a4e282ad - Show all commits
+16
View File
@@ -92,6 +92,22 @@ describe('radix index: local and remote trees', () => {
});
});
describe('radix index: ranking across branches', () => {
it('lets an exact param route beat a catch-all the walk reached first through a static branch', () => {
// The static branch is walked first and yields the catch-all (rank 1); the param sibling still
// holds the rank-0 exact route, so pruning must not cut it, even by one.
for (const order of [
['/a/:rest*', '/:x/b'],
['/:x/b', '/a/:rest*'],
]) {
const routes = order.map((pattern) => route('GET', pattern));
const expected = oracle.matchRoute(routes, 'GET', '/a/b');
expect(expected?.def.pattern).toBe('/:x/b');
expect(live.matchRoute(routes, 'GET', '/a/b')).toEqual(expected);
}
});
});
describe('radix index: lifetime', () => {
it('rebuilds when the array it was built from changes length', () => {
const routes = [route('GET', '/a')];