route-map

1.0.0 • Public • Published

route-map

Match a url from an object of route patterns.

Republished from @azer.

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

/route-map/

    Package Sidebar

    Install

    npm i route-map

    Weekly Downloads

    37

    Version

    1.0.0

    License

    ISC

    Last publish

    Collaborators

    • nichoth