Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    route-mappublic

    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

    install

    npm i route-map

    Downloadsweekly downloads

    193

    version

    1.0.0

    license

    ISC

    repository

    githubgithub

    last publish

    collaborators

    • avatar