matchPathTemplates()function

matchPathTemplates(templates: Iterable<AbsolutePath> & NotString, target: AbsolutePath): TemplateMatches | undefined
ParamType
templatesIterable<AbsolutePath> & NotString
Iterable of path-shaped template strings to try in order, e.g. ["/users/{name}", "/users"]. required
targetAbsolutePath
The path containing values, e.g. /users/Dave. required
Return
TemplateMatches | undefined
An object of values for the first matching template, or undefined if none match.

Match multiple path-shaped templates against a target path and return the first match.

Examples

matchPathTemplates(["/users/{name}", "/users"], "/users/Dave") // { name: "Dave" }