url-match

url-match is a pattern matching for urls paths and query parameters

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
url-match
0.1.08 years ago8 years agoMinified + gzip package size for url-match in KB

Readme

url-match
url-match is a pattern matching for urls paths and query parameters based on the backbone router and the plugin backbone-query-parameters

install

npm install url-match

or
put this line in the dependencies section of your package.json:
"url-match": "0.1.0"

then run:
npm install

require

var urlMatch = require('url-match');

match urls

make pattern from string
var pattern = urlPattern.generate('/users/:id');
match pattern against url
match returns the extracted parameters or null if there was no match:
pattern.match('/projects/5'); // => null
pattern.match('/users/5'); // => [{id: '5'}, {}]
pattern.match('/users/5?a=b&c=d'); // => [{id: '5'}, {a: "b", c: "d"}]