Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/path_to_regexp/index.ts>pathToRegexp

Turn a path string such as `/user/:name` into a regular expression
Go to Latest
function pathToRegexp
import { pathToRegexp } from "https://deno.land/x/path_to_regexp@v7.1.0/index.ts";

Normalize the given path string, returning a regular expression.

An empty array can be passed in for the keys, which will hold the placeholder key descriptions. For example, using /user/:id, keys will contain [{ name: 'id', delimiter: '/', optional: false, repeat: false }].

Parameters

path: Path
optional
options: PathToRegexpOptions = [UNSUPPORTED]