0.6.3 • Published 4 years ago
node-match-path v0.6.3
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')
/*
{
matches: true,
params: {
userId: '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')
/*
{
matches: true,
params: null
}
*/
Path parameters
match('/admin/:messageId', '/admin/abc-123')
/*
{
matches: true,
params: {
messageId: 'abc-123'
}
}
*/
Wildcard
match('/user/*/inbox', '/user/abc-123/inbox')
/*
{
matches: true,
params: null
}
*/
Regular expression
match(/\/messages\/.+?\/participants/, '/messages/5/participants')
/*
{
matches: true,
params: null
}
*/
Honorable mentions
0.6.3
4 years ago
0.6.2
4 years ago
0.6.1
4 years ago
0.6.0
4 years ago
0.5.2
4 years ago
0.5.1
4 years ago
0.5.0
5 years ago
0.4.4
5 years ago
0.4.3
5 years ago
0.4.1
5 years ago
0.4.2
5 years ago
0.4.0
5 years ago
0.3.1
5 years ago
0.3.0
5 years ago
0.2.1
5 years ago
0.2.3
5 years ago
0.2.2
5 years ago
0.2.0
5 years ago
0.1.0
6 years ago