path-params
v0.1.0
Published
Replace path params based on express route notation
Downloads
3,083
Maintainers
Readme
path-params

Replace path params based on express
route notation.
Installation
Via npm:
npm install path-params --save
Via bower:
bower install path-params --save
Or loading the script:
<script src="//cdn.rawgit.com/h2non/path-params/master/path-params.js"></script>
Environments
Runs in any ES5 compliant engine:
|
|
|
|
|
--- | --- | --- | --- | --- | --- |
+0.8 | +5 | +3.5 | +9 | +12 | +5 |
Usage
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'
}
API
pathParams(path, params) => String|Error
License
MIT © Tomas Aparicio