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.
Thin wrapper around path-to-regexp to make extracting the param names easier.
varroute=require('path-match')({// path-to-regexp optionssensitive: false,strict: false,end: false,});// create a match function from a routevarmatch=route('/post/:id');// match a routevarparse=require('url').parse;require('http').createServer(function(req,res){varparams=match(parse(req.url).pathname);// no matchif(params===false){res.statusCode=404;res.end();return;}// the matched idvarid=params.id;// do stuff with the ID})