Skip to content

egoist/path-extract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

path-extract

NPM version NPM downloads Build Status donate

Install

yarn add path-extract

Usage

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, Released under the MIT License.
Authored and maintained by egoist with help from contributors (list).

egoistian.com · GitHub @egoist · Twitter @rem_rin_rin

About

A light-weight implementation for easy route parameters

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published