rizo/helix

Allow specializing routes

Closed this issue · 1 comments

rizo commented

When the following routes are registered, the most specific one should match.

Routes:

r0 /users/:id/:x
r1 /users/:id/**
r2 /users/:id/edit
r3 /users/:id/edit/extra
r4 /users/0/edit

Both r0 and r1 are "terminal" routes, r1 will overwrite r0. While r4 does not overwrite other routes.

Inputs:

i1 /users/1/overview -> r1
i2 /users/1/edit -> r2
i3 /users/1/edit/extra -> r3
i4 /users/1/edit/foo -> none
i5 /users/0/edit -> r4
i6 /users/0/edit/extra -> none

In other words:

Const > Var > Rest

We don't want to allow backtracking for failed inputs (i4 and i6). When routes are specialized, they create their own matching trees.

Maybe this can be revisted in the future, in which case, the lookup would backtrack to the latest ** node.

rizo commented

The fully backtracking solution is implemented in 2b4fda6.