Skip to content

Function: getCompiledPattern()

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

function getCompiledPattern(pattern, options?): URLPatternLike;

Defined in: packages/play-url/src/url-pattern-utils.ts:187

Compiles a route pattern into a URLPattern, and it uses the cache of the module level again.

ParsedPattern.normalized carries the pattern that the compilation reads. A param name with a hyphen (:cat-id) therefore becomes a valid URLPattern identifier (:cat_id). A caller that reads the values of the groups must map each normalized name back with ParsedPattern.declaredNames.

Parameters

ParameterTypeDescription
patternstringThe string of the route pattern, for example /profile/:userId
optionsCompileOptionsSee CompileOptions. This function reads TWO caches, so neither option is named cache: one holds the PARSE and the other holds the COMPILED pattern.

Returns

URLPatternLike

Throws

When URLPattern cannot compile the pattern.