Can add a function as to match a route. The function takes in a string
url segment and returns some value if the route matches or returns null
or undefined for no match.
Example usage:
function toInt(part) {
var results = /^(\d+)$/.exec(part)
return results ? parseInt(results[0], 10) : null
}
var router = new Router()
router.add(['/by/order', toInt], function (val) {
// val === 123
})
router.route('/by/order/123')
|
||
|---|---|---|
| .. | ||
| route-node.js | ||
| router.js | ||
| utils.js | ||