https://github.com/marvinhagemeister/fast-path-to-regexp
Tiny & fast alternative to path-to-regexp
https://github.com/marvinhagemeister/fast-path-to-regexp
path path-to-regexp regex url
Last synced: about 2 months ago
JSON representation
Tiny & fast alternative to path-to-regexp
- Host: GitHub
- URL: https://github.com/marvinhagemeister/fast-path-to-regexp
- Owner: marvinhagemeister
- License: mit
- Created: 2017-12-28T15:23:17.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:40:07.000Z (over 2 years ago)
- Last Synced: 2025-03-28T23:34:48.935Z (2 months ago)
- Topics: path, path-to-regexp, regex, url
- Language: TypeScript
- Homepage:
- Size: 1.43 MB
- Stars: 18
- Watchers: 3
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Fast Path To RegExp
Ultra small and super fast library for converting paths
to `RegExp`. Only implements a subset of [path-to-regexp](https://github.com/pillarjs/path-to-regexp).```txt
:myparam -> named parameters, f.ex. /bar/:foo
* -> wildcard catchall, f.ex. /bar/*/foo
```## Usage
Installation:
```bash
# via npm
npm install --save @marvinh/path-to-regexp# via yarn
yarn add @marvinh/path-to-regexp
``````js
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](./LICENSE.md).