MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / compilePattern

Method compilePattern

src/api/APIRouter.ts:23–32  ·  view source on GitHub ↗
(pattern: string)

Source from the content-addressed store, hash-verified

21 private routes: Route[] = [];
22
23 private compilePattern(pattern: string): { regex: RegExp; paramNames: string[] } {
24 const paramNames: string[] = [];
25 const regexPattern = pattern.replace(/:([a-zA-Z_][a-zA-Z0-9_]*)/g, (match, paramName) => {
26 paramNames.push(paramName);
27 return "([^/]+)";
28 });
29
30 const regex = new RegExp(`^${regexPattern}$`);
31 return { regex, paramNames };
32 }
33
34 register(method: HTTPMethod, pattern: string, handler: RouteHandler): void {
35 const { regex, paramNames } = this.compilePattern(pattern);

Callers 1

registerMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected