@marvinh/path-to-regexp
v3.1.0
Published
Ultra small and fast path to regex generation
Downloads
1,674
Readme
Fast Path To RegExp
Ultra small and super fast library for converting paths
to RegExp
. Only implements a subset of path-to-regexp.
:myparam -> named parameters, f.ex. /bar/:foo
* -> wildcard catchall, f.ex. /bar/*/foo
Usage
Installation:
# via npm
npm install --save @marvinh/path-to-regexp
# via yarn
yarn add @marvinh/path-to-regexp
import { PathRegExp } from "@marvinh/path-to-regexp";
const Path = new PathRegExp("foo/:bar/*/bob");
// Returns params on match
Path.match("foo/asd/a/");
// -> {
// matched: "", // The remaining part if any
// params: { bar: "asd" }
// }
License
MIT
, see License file.