Skip to content

Commit 7e53c66

Browse files
committed
fix bug when the only first router was matched
1 parent 4e8d5e7 commit 7e53c66

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,10 @@ function mock(superagent) {
4545
* TODO: Remove data
4646
*/
4747
function match(method, url, data) {
48-
var match;
49-
var i = callbacks.length;
50-
callbacks.forEach(function(callback) {
51-
var m = callbacks[i-1].match(method, url, data);
52-
if (m) match = m;
53-
});
54-
return match;
48+
return callbacks.reduce(function(memo, cb) {
49+
var m = cb.match(method, url, data);
50+
return m ? m : memo;
51+
}, {});
5552
}
5653

5754
/**

0 commit comments

Comments
 (0)