miniroutes
Mini routing system based on regular expressions.
Usage
var miniroutes = ; var paths = // Match 'foo' and 'foo/' 'foo' /^foo\/?$/ // Match 'bar', 'bar/<anything>', 'bar/<anything>/<anything>' 'bar' /^bar??\/?$/ ; var routing = ; ;// Console output: { name: 'foo',// params: [],// value: 'foo' } ;// Console output: { name: 'bar',// params: ['param1', null],// value: 'bar/param1' } ;// Console output: { name: 'bar',// params: ['param1', 'param2'],// value: 'bar/param1/param2' }
You can also combine miniroutes with minihash:
var miniroutes = ;var minihash = ; var routes = /* … */ ; var hash = ;
Installation
$ npm install miniroutes
Browser compatibility
IE9+ and modern browsers.
License
Special thanks
Illustration made by Raphaël Bastide with scri.ch.