node-match-path
Matches a URL against the given path.
Getting started
Install
npm install node-match-path
Usage
const { match } = require('node-match-path')
match('/user/:userId', '/user/5')
API
match(path: RegExp | string, url: string): Match
Returns a match data, if any, between a url and a path.
String path
match('/admin', '/admin')
Path parameters
match('/admin/:messageId', '/admin/abc-123')
Wildcard
match('/user/*/inbox', '/user/abc-123/inbox')
Regular expression
match(/\/messages\/.+?\/participants/, '/messages/5/participants')
Honorable mentions