Function: getIndexKey()
API / @xmachines/play-pattern / getIndexKey
function getIndexKey(path): string;Defined in: play-pattern/src/pattern-grammar.ts:201
Computes the key of the bucket index of a concrete PATH.
The key is the first path segment, for example "settings" of "/settings/billing".
The root path "/" gives the key "/", and a path whose first segment is EMPTY —
"//docs" — gives the key "". The two are different keys, so a pattern that matches
both asks ParsedPattern.indexKey for the wildcard key instead.
ParsedPattern.indexKey computes the key of a PATTERN, and it calls this function for every pattern whose first segment is a literal. One function therefore answers both sides, and a pattern in the wrong bucket cannot happen.
Parameters
| Parameter | Type | Description |
|---|---|---|
path | string | The string of a URL path. |
Returns
string