v3.1.0
Features
-
Support
RegExp
route patterns: (#11): af37967You may use named capture groups, which will automatically set
req.params
values.
However, they're only supported in Node 10.x and above~!Checkout the new documentation from
regexparam
for more details.app.get(/^\/posts[/](?<year>[0-9]{4})[/](?<month>[0-9]{2})[/](?<title>[^\/]+)/i, (req, res) => { console.log(req.params.year); //=> '2019' console.log(req.params.month); //=> '05' console.log(req.params.title); //=> 'hello-world' }); app.find('GET', '/posts/2019/05/hello-world');
Thank you @jirutka for instigating and working on this feature!