Replace path params based on express route notation
npm install path-paramsReplace path params based on express route notation.
Via npm:
``bash`
npm install path-params --save
Via bower:
`bash`
bower install path-params --save
Or loading the script:
`html`
Runs in any ES5 compliant engine:
!Node.js | !Chrome | !Firefox | !IE | !Opera | !Safari
--- | --- | --- | --- | --- | --- |
+0.8 | +5 | +3.5 | +9 | +12 | +5 |
`js
const pathParams = require('path-params')
const path = pathParams('/users/:id/:action', { id: 123, action: 'foo' })
if (path instanceof Error) {
console.error('Params error:', err.message)
} else {
console.log('Path:', path) // -> '/users/123/foo'
}
``
MIT © Tomas Aparicio
[travis]: http://travis-ci.org/h2non/path-params