router-params

2.0.2 • Public • Published

Router Params

tiny url parameter parsing utility for use with routers. Works just like express router

Install

npm i router-params --save

Usage

Simplest working example

var routerParams = require('router-params')
var matcher = routerParams('/thing/:comment/:id')
matcher('/thing/123/456')
// outputs {comment: '123',id: '456'}

Routes with no parameters return false

var routerParams = require('router-params')
var routePatterns = []
var matcher = routerParams('/thing')// false
if (matcher) {
 routePatterns.push(matcher)
}

Test

npm test

Package Sidebar

Install

npm i router-params

Weekly Downloads

2

Version

2.0.2

License

Apache-2.0

Last publish

Collaborators

  • dam