path-match
wrapper around path-to-regexp for easy route parameters
Last updated 9 years ago by jongleberry .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install path-match 
SYNC missed versions from official npm registry.

path match

NPM version Build status Test coverage Dependency Status License Downloads

Thin wrapper around path-to-regexp to make extracting the param names easier.

var route = require('path-match')({
  // path-to-regexp options
  sensitive: false,
  strict: false,
  end: false,
});

// create a match function from a route
var match = route('/post/:id');

// match a route
var parse = require('url').parse;
require('http').createServer(function (req, res) {
  var params = match(parse(req.url).pathname);

  // no match
  if (params === false) {
    res.statusCode = 404;
    res.end();
    return;
  }

  // the matched id
  var id = params.id;

  // do stuff with the ID
})

Current Tags

  • 1.2.4                                ...           latest (9 years ago)

8 Versions

  • 1.2.4                                ...           9 years ago
  • 1.2.3                                ...           9 years ago
  • 1.2.2                                ...           10 years ago
  • 1.2.1                                ...           10 years ago
  • 1.2.0                                ...           10 years ago
  • 1.1.1                                ...           10 years ago
  • 1.1.0                                ...           10 years ago
  • 1.0.0                                ...           11 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (2)
Dependents (1)

Copyright 2013 - present © cnpmjs.org | Home |