@marvinh/path-to-regexp
v3.1.0
Published
Ultra small and fast path to regex generation
Downloads
512
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/*/fooUsage
Installation:
# via npm
npm install --save @marvinh/path-to-regexp
# via yarn
yarn add @marvinh/path-to-regexpimport { 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.
