Skip to content

Function: getCompiledPattern()

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

function getCompiledPattern(pattern): URLPatternLike;

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

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

normalizeParamNames normalizes the pattern before the compilation. 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 getNormalizedParamNameMap.

Parameters

ParameterTypeDescription
patternstringThe string of the route pattern, for example /profile/:userId

Returns

URLPatternLike

Throws

When URLPattern cannot compile the pattern.