matchPathTemplates()function
matchPathTemplates(templates: Iterable<AbsolutePath> & NotString, target: AbsolutePath): TemplateMatches | undefined
| Param | Type | |
|---|---|---|
templates | Iterable<AbsolutePath> & NotString | Iterable of path-shaped template strings to try in order, e.g. ["/users/{name}", "/users"]. required |
target | AbsolutePath | 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" }