@marvinh/path-to-regexp
TypeScript icon, indicating that this package has built-in type declarations

3.1.0 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i @marvinh/path-to-regexp

Weekly Downloads

212

Version

3.1.0

License

MIT

Unpacked Size

30.6 kB

Total Files

13

Last publish

Collaborators

  • eaderhold
  • marvinhagemeister