Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

pillarjs/path-match

Repository files navigation

Caution

This repository is archived and no longer actively maintained.

We are no longer accepting issues, feature requests, or pull requests. For additional support or questions, please visit the Express.js Discussions page.

path match

NPM version Node.js CI codecov 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
})

About

please use path-to-regexp's `match` function

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 3

  •  
  •  
  •