|
|
|
@ -48,27 +48,30 @@ assign(RouteNode.prototype, {
|
|
|
|
|
get: function get(parts, args, done) {
|
|
|
|
|
parts = parts || []
|
|
|
|
|
args = args || []
|
|
|
|
|
|
|
|
|
|
if (parts.length === 0) {
|
|
|
|
|
return done(null, this.handler, this.context, args)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var part = parts.shift()
|
|
|
|
|
var childNode = this._children[part]
|
|
|
|
|
if (childNode) {
|
|
|
|
|
return childNode.get(parts, args, done)
|
|
|
|
|
} else {
|
|
|
|
|
var results = this._getRegexChild(part)
|
|
|
|
|
if (results && results.node) {
|
|
|
|
|
return results.node.get(parts, args.concat(results.args), done)
|
|
|
|
|
} else {
|
|
|
|
|
results = this._getFunctionChild(part)
|
|
|
|
|
if (results && results.node) {
|
|
|
|
|
return results.node.get(parts, args.concat(results.args), done)
|
|
|
|
|
} else {
|
|
|
|
|
return done(new Error('not found'))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check exact matches
|
|
|
|
|
if (this._children[part]) {
|
|
|
|
|
return this._children[part].get(parts, args, done)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check regex matches
|
|
|
|
|
var results = this._getRegexChild(part)
|
|
|
|
|
if (results && results.node) {
|
|
|
|
|
return results.node.get(parts, args.concat(results.args), done)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check function matches
|
|
|
|
|
results = this._getFunctionChild(part)
|
|
|
|
|
if (results && results.node) {
|
|
|
|
|
return results.node.get(parts, args.concat(results.args), done)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return done(new Error('not found'))
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_getRegexChild: function _getRegexChild(part) {
|
|
|
|
|