Skip to content

Commit 2048900

Browse files
committed
Update stale router design in uri-template README
The README described candidate lookup as a single prefix trie keyed by the initial literal prefix of each route. After the state-trie change, lookup combines a token-level state trie for indexable path templates with a fallback prefix trie for the remaining RFC 6570 shapes. Rewrite the bullet so the documented design matches the implementation. #758 (comment) Assisted-by: Claude Code:claude-opus-4-7
1 parent db56e0b commit 2048900

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

packages/uri-template/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,15 @@ The important differences are:
105105
- `Router.variables()` and `Router.compile()` expose variable extraction
106106
without mutating a router. The legacy `Router.add()` returned variables as
107107
a side effect of registering the route.
108-
- Candidate lookup uses a prefix trie keyed by the initial literal prefix of
109-
each route. Candidates are ordered deterministically by literal length,
110-
initial literal prefix length, variable count, and insertion order before
111-
the round-trip matcher runs.
108+
- Candidate lookup combines a token-level state trie with a fallback prefix
109+
trie. Indexable path templates—those whose expressions each hold a single
110+
variable with the `""`, `/`, or `+` operator and never sit directly
111+
adjacent to another expression—are walked token by token in the state
112+
trie. Shapes that cannot be safely indexed fall back to a prefix trie
113+
keyed by the initial literal prefix of each route. Candidates from both
114+
tries are merged, deduplicated, and ordered deterministically by literal
115+
length, initial literal prefix length, variable count, and insertion order
116+
before the round-trip matcher runs.
112117
- Cloning and route replacement do not depend on copying private mutable
113118
state from [uri-template-router]. The router stores compiled templates and
114119
active route entries directly, which keeps the implementation independent

0 commit comments

Comments
 (0)