Match a url from an object of route patterns
JavaScript
Switch branches/tags
Nothing to show
Latest commit 44982d8 Apr 23, 2014 @azer 0.1.0
Permalink
Failed to load latest commit information.
.gitignore
.npmignore
README.md
index.js
package.json
test.js

README.md

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