Skip to content

Function: isParameterizedPattern()

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

function isParameterizedPattern(pattern): boolean;

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

Tells you if a route path needs a URLPattern match, and is not a concrete URL.

A pattern holds a param — :name, (\d+) or * — or a {…} group, or an escape. Each of them needs a match, and each of them carries no concrete value, so the code can push such a path to a browser URL never.

This function is THE single source of truth of the question “is this path a pattern?”. RouteMap uses it for its decision between the static map and the index of the pattern buckets, and extractRouteParams uses it to answer {} for a literal path. A CONCRETE path asks holdsUnsubstitutedParam instead, and never this function.

The answer comes from the parse, and not from a search for a : or a *. That search called /a{/b}?/c a static path, and RouteMap then put it in the exact-match map, where the path /a/c reached it never.

Parameters

ParameterTypeDescription
patternstringThe string of a URL path or of a route pattern, for example /profile/:userId or /docs/*

Returns

boolean

true when the path needs a URLPattern match