Skip to content

Commit

Permalink
Merge pull request #539 from mclotworthy/master
Browse files Browse the repository at this point in the history
Remove Regex "matched text"
  • Loading branch information
matthewp authored May 29, 2019
2 parents aee9de8 + f2ce742 commit 7f8e01d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions page.js
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,8 @@ pathToRegexp_1.tokensToRegExp = tokensToRegExp_1;
m = this.regexp.exec(decodeURIComponent(pathname));

if (!m) return false;

delete params[0]

for (var i = 1, len = m.length; i < len; ++i) {
var key = keys[i - 1];
Expand Down
8 changes: 8 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,14 @@
});
page('/ctxparams/test/');
});

it('should handle optional first param', function(done) {
page(/^\/ctxparams\/(option1|option2)?$/, function(ctx) {
expect(ctx.params[0]).to.be.undefined;
done();
});
page('/ctxparams/');
});
});

describe('ctx.handled', function() {
Expand Down

0 comments on commit 7f8e01d

Please sign in to comment.