A light-weight implementation for easy route parameters
MIT License
yarn add path-extract
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
git checkout -b my-new-feature
git commit -am 'Add some feature'
git push origin my-new-feature
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