Builds a regular expression for matching route paths based on route options.
The path regex is used purely as a matching predicate (uriMatcher); it does not need to preserve parameter names for extraction, so it names its groups locally.
uriMatcher
The route options to build the regex from.
Regular expression flags, defaults to 'i' (case insensitive).
A regular expression for matching route paths.
const regex = pathRegex({ path: '/users/:id', strict: false });console.log(regex.test('/users/123')); // true Copy
const regex = pathRegex({ path: '/users/:id', strict: false });console.log(regex.test('/users/123')); // true
Builds a regular expression for matching route paths based on route options.
The path regex is used purely as a matching predicate (
uriMatcher); it does not need to preserve parameter names for extraction, so it names its groups locally.