oag-mcp
    Preparing search index...

    Function compilePathTemplate

    • Compile a path template into a matcher over URL paths. A parameter matches one or more characters other than /, as [^/]+ would, and one trailing slash is allowed. Matching works segment by segment without regular expressions, so it takes linear time whatever the path: a template with several parameters in one segment, such as /files/{name}.{ext}, cannot be made to backtrack.

      This replaces a regular expression with [^/]+ for each parameter. Against a template with several parameters in one segment, that regex backtracked quadratically on a long request path, and since the broker runs in the server's own process, one request could block the server for minutes. Paths are now matched in linear time, and request URLs over MAX_URL_LENGTH (8,192 characters) are refused before matching.

      Parameters

      • basePath: string

        base URL path without trailing slash

      • template: string

        OpenAPI path template

      Returns PathMatcher

      matcher with a test(path) method