route-map

Match a url from an object of route patterns

npm install route-map
10 downloads in the last day
27 downloads in the last week
129 downloads in the last month

route-map

Match a url from an object of route patterns

Install

$ npm install route-map

Usage

routeMap = require('route-map')

match = routeMap({
  '/people/:name': showUser,
  '/pages/:page': showPage
})

match('http://foobar.com/people/john?foo=bar')
// => {
//       fn: showUser,
//       params: { name: 'john' },
//       qs: { foo: 'bar' }, // querystring
//       pattern: 'people/:name',
//       url: 'people/john?foo=bar'
//    }

match('nonexisting')
// => undefined
npm loves you