106 unmodified lines
Expand all
* @api private
*/
Layer.prototype.match = function match(path) {
if (path == null) {
// no path, nothing matches
this.params = undefined;
this.path = undefined;
return false;
}
var match
if (path != null) {
if (this.regexp.fast_slash) {
// fast path non-ending match for / (everything matches)
this.params = {};
this.path = '';
return true;
if (this.regexp.fast_slash) {
// fast path non-ending match for / (everything matches)
this.params = {}
this.path = ''
return true
}
// match the path
match = this.regexp.exec(path)
}
var m = this.regexp.exec(path);
if (!m) {
if (!match) {
this.params = undefined;
this.path = undefined;
return false;
}
// store values
this.params = {};
this.path = m[0];
this.path = match[0]
var keys = this.keys;
var params = this.params;
for (var i = 1; i < m.length; i++) {
for (var i = 1; i < match.length; i++) {
var key = keys[i - 1];
var prop = key.name;
var val = decode_param(m[i]);
var val = decode_param(match[i])
if (val !== undefined || !(hasOwnProperty.call(params, prop))) {
params[prop] = val;
}