Skip to content

Function: getIndexKey()

API / @xmachines/play-url / index / getIndexKey

function getIndexKey(path): string;

Defined in: packages/play-url/src/pattern-grammar.ts:199

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

ParameterTypeDescription
pathstringThe string of a URL path.

Returns

string