path-match
wrapper around path-to-regexp for easy route parameters
Last updated 5 years ago by jongleberry .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm 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 (5 years ago)

8 Versions

  • 1.2.4                                ...           5 years ago
  • 1.2.3                                ...           5 years ago
  • 1.2.2                                ...           6 years ago
  • 1.2.1                                ...           6 years ago
  • 1.2.0                                ...           6 years ago
  • 1.1.1                                ...           6 years ago
  • 1.1.0                                ...           7 years ago
  • 1.0.0                                ...           7 years ago
Downloads
Today 13
This Week 1,105
This Month 9,191
Last Day 576
Last Week 3,076
Last Month 9,503
Dependencies (2)
Dev Dependencies (2)
Dependents (221)

Copyright 2014 - 2017 © taobao.org |