Skip to content

Commit

Permalink
Missing test case in the urlParser.
Browse files Browse the repository at this point in the history
Caused a bug for existing projects where the routes were parsed in the
wrong order, causing the last route to be the default.
  • Loading branch information
EdJ committed Jun 13, 2013
1 parent e866c08 commit 56f1310
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Routes/urlParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = (function() {
var pattern;
var output;

for (var i = patterns.length; i--;) {
for (var i = 0, l = patterns.length; i < l; i++) {
pattern = patterns[i];

output = pattern.func(path);
Expand Down
31 changes: 30 additions & 1 deletion test/Routes/urlParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,36 @@ describe('UrlParser', function() {
}
}
], ['/Content']);


var path = parseUrl('/test/test.html');

path.should.eql({
test: 'data',
_isStatic: false
});
});

it('should check the routes in order.', function() {
var parseUrl = urlParser([{
func: function() {
return {};
},
data: {
test: 'data'
}
}, {

func: function() {
return {
wrongData: true
}
},
data: {
nope: 'not this one.'
}
}
], ['/Content']);

var path = parseUrl('/test/test.html');

path.should.eql({
Expand Down

0 comments on commit 56f1310

Please sign in to comment.