Skip to content

Commit d735dd0

Browse files
committed
Don't match if fixed rule is longer than path
Closes #1
1 parent ba0fa5b commit d735dd0

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pathparser.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
var params = {};
3434
var missingParams = {};
3535

36+
// Don't match if fixed rule is longer than path
37+
if (rule.parts.length < pathParts.length) return false;
38+
3639
// Parse path components
3740
for (var i = 0; i < rule.parts.length; i++) {
3841
var rulePart = rule.parts[i];

test/tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ test("Multi-part fixed path", function () {
4545
router.run('items');
4646
});
4747

48-
test("Don't match fixed path against incomplete fixed rule", function () {
48+
test("Don't match fixed path with additional parts", function () {
4949
var router = new PathParser;
5050
router.add('items', function () {
5151
throw new Error("Incorrect match");

0 commit comments

Comments
 (0)