code: function findRule(path, rules) {
     var matchingRule = null;
  
     for (var i=0; i < rules.length; i++) {
  	   var rule = rules[i];
  
  	   if (typeof rule.pattern === 'string') {
  		   if (path.indexOf(rule.pattern) !== 0) {
  			   continue;
  		   }
  
  		   // The longest matching rule takes precedence
  		   if (!matchingRule || rule.pattern.length > matchingRule.pattern.length) {
  			   matchingRule = rule;
  		   }
  	   // The first matching pattern takes precedence
  	   // over all other rules including other patterns
  	   } else if (rule.pattern.test(path)) {
  		   return rule;
  	   }
     }
  
     return matchingRule;
  }
docs: Returns if a pattern is allowed by the specified rules.
  
  @param  {string}  path
  @param  {Array.<Object>}  rules
  @return {Object?}
  @private