Lesson 6.2

Lookup, backtracking, and precedence

How lookup tries static, then param, then wildcard with backtracking, allocates the params object only on capture, and reports the allowed set on a method miss.

42 minsrc/router.js
  • Trace a lookup that backtracks from a failed static descent into a param child.
  • Apply static beats param beats wildcard at every node.
  • Allocate params lazily and percent-decode only on a % byte.
  • Return find's allowed variant on a method miss so the caller can tell 405 from 404.
Locked

This chapter is part of the framework capstone. Chapters 1 and 2 are free to build - unlock the rest to keep going.

Unlock the depth