https://github.com/egoist/path-extract
A light-weight implementation for easy route parameters
https://github.com/egoist/path-extract
path-to-regexp route router
Last synced: about 1 month ago
JSON representation
A light-weight implementation for easy route parameters
- Host: GitHub
- URL: https://github.com/egoist/path-extract
- Owner: egoist
- License: mit
- Created: 2017-02-09T14:28:52.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2021-12-25T14:36:58.000Z (over 3 years ago)
- Last Synced: 2025-04-23T01:01:48.285Z (about 2 months ago)
- Topics: path-to-regexp, route, router
- Language: JavaScript
- Homepage:
- Size: 38.1 KB
- Stars: 6
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# path-extract
[](https://npmjs.com/package/path-extract) [](https://npmjs.com/package/path-extract) [](https://circleci.com/gh/egoist/path-extract) [](https://github.com/egoist/donate)
## Install
```bash
yarn add path-extract
```## Usage
```js
const extract = require('path-extract')extract('/user/:username/post/:id', '/user/egoist/post/1')
//=> params:
{
username: 'egoist',
id: '1'
}extract('/user/*', '/user/egoist/post/1')
//=> params:
{
'*': 'egoist/post/1'
}extract('/user/:id', '/list/foo')
//=> null
```## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D## Author
**path-extract** © [egoist](https://github.com/egoist), Released under the [MIT](./LICENSE) License.
Authored and maintained by egoist with help from contributors ([list](https://github.com/egoist/path-extract/contributors)).> [egoistian.com](https://egoistian.com) · GitHub [@egoist](https://github.com/egoist) · Twitter [@rem_rin_rin](https://twitter.com/rem_rin_rin)