You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
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')
|
10 years ago | |
|---|---|---|
| .. | ||
| route-node.js | 10 years ago | |
| router.js | 10 years ago | |
| utils.js | 10 years ago | |