MCPcopy Create free account
hub / github.com/denoland/std / tryRoute

Function tryRoute

http/unstable_route.ts:349–357  ·  view source on GitHub ↗

* Try a single route as a candidate. Updates `state` in place when the * route matches and has a lower insertion index than the current best.

(state: MatchState, r: IndexedRoute)

Source from the content-addressed store, hash-verified

347 * route matches and has a lower insertion index than the current best.
348 */
349 function tryRoute(state: MatchState, r: IndexedRoute): void {
350 if (r.index >= state.bestIndex) return;
351 if (!methodMatches(r.route.method, state.request.method)) return;
352 const params = r.route.pattern.exec(state.request.url);
353 if (!params) return;
354 state.bestRoute = r.route;
355 state.bestIndex = r.index;
356 state.bestParams = params;
357 }
358
359 /**
360 * Walk the tree in lockstep with the pathname. `from` is the index of the

Callers 2

walkFunction · 0.85
routeRadixFunction · 0.85

Calls 1

methodMatchesFunction · 0.85

Tested by

no test coverage detected