Interface: ParsedPattern
API / @xmachines/play-pattern / ParsedPattern
Defined in: pattern-grammar.ts:117
Everything that this library reads from one route pattern.
Properties
| Property | Modifier | Type | Description | Defined in |
|---|---|---|---|---|
bareForm | readonly | string | null | The path that the pattern matches when every optional part is absent, or null when the pattern holds a part that a path must fill. /settings/:section? gives /settings, /a/{b}?/c gives /a//c, and /profile/:userId gives null. | pattern-grammar.ts:154 |
declaredNames | readonly | ReadonlyMap<string, string> | The map from each rewritten group name back to the name that the pattern declares, for example cat_id to cat-id. The map holds an entry only for a name that the rewrite changed. It is empty for most patterns, and a caller that reads a group name falls back to the name itself. | pattern-grammar.ts:184 |
indexKey | readonly | string | The key of the bucket index: the first path segment, or "*" when a param can stand in the first segment. | pattern-grammar.ts:171 |
literalPath | readonly | string | null | The ONE path that the pattern matches, with each escape resolved, or null when the pattern describes a SET of paths. /users gives /users, /tags/c\+\+ gives /tags/c++, /x{y}z gives /xyz, and /profile/:userId gives null. A bridge writes a real browser URL from this field. The SOURCE of the pattern is no substitute for it: /tags/c\+\+ carries two backslashes that the address bar must not hold, and a location that carries them matches the route never. | pattern-grammar.ts:166 |
names | readonly | readonly string[] | The name of every param of params, in the same order. resolveFrameworkParams runs on EVERY navigation and it needs this list each time. The parse holds it, so a navigation allocates none. A caller that hands the array to somebody else copies it: the cache holds this one. | pattern-grammar.ts:131 |
normalized | readonly | string | The pattern in the form that URLPattern compiles: each param name that holds a hyphen carries an underscore instead. | pattern-grammar.ts:176 |
parameterized | readonly | boolean | True when the pattern needs a URLPattern match, and false when it is a literal path. A malformed pattern reports true, so that it reaches the URLPattern constructor and fails there with the error of the API. A parser that called it static would send it to the exact-match map instead, where it matches nothing and reports no fault. | pattern-grammar.ts:146 |
params | readonly | readonly PatternParam[] | The NAMED params, in the order that the pattern declares them. | pattern-grammar.ts:123 |
parts | readonly | readonly PatternPart[] | The parts, in the order that the pattern declares them. | pattern-grammar.ts:121 |
requiredNames | readonly | readonly string[] | The name of every param that a path must fill, in the order of params. The same rule as names: the parse holds the array, and a navigation reads it. | pattern-grammar.ts:137 |
source | readonly | string | The pattern as the caller wrote it. | pattern-grammar.ts:119 |