0.1.0 • Published 8 years ago

path-params v0.1.0

Weekly downloads
118
License
MIT
Repository
github
Last release
8 years ago

path-params Build Status NPM js-standard-style

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:

Node.jsChromeFirefoxIEOperaSafari
+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