Skip to content

Function: getPatternParamNames()

API / @xmachines/play-router / index / getPatternParamNames

function getPatternParamNames(pattern): string[];

Defined in: packages/play-url/src/framework-params.ts:26

Reads the names of every :param of a route pattern of the route map.

The names come from the parse of pattern-grammar.ts, which reads the WHOLE grammar: a {…} group and a (\d+) constraint both hide a name from an expression that looks for :name alone. An ANONYMOUS param — * and a bare (\d+) — carries no name, and the list therefore holds none.

Parameters

ParameterTypeDescription
patternstringA route pattern, for example /profile/:userId.

Returns

string[]

The names, in the order that the pattern declares them. A fresh array, because parsePattern caches the parse that it reads.