Skip to content

Commit

Permalink
test: cover matching literal parenthesis in capturing groups
Browse files Browse the repository at this point in the history
  • Loading branch information
nfantone committed Nov 17, 2021
1 parent e905e7f commit 9c4e973
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,7 @@ describe('Router', function () {
.expect(200, { 0: 's', user: 'tj', op: 'edit' }, cb)
})

it('should work inside literal paranthesis', function (done) {
it('should work inside literal parenthesis', function (done) {
var router = new Router()
var route = router.route('/:user\\(:op\\)')
var server = createServer(router)
Expand All @@ -700,6 +700,27 @@ describe('Router', function () {
.expect(200, { user: 'tj', op: 'edit' }, done)
})

it('should allow matching literal parenthesis within a group', function (done) {
var cb = after(3, done)
var router = new Router()
var route = router.route('/:user([a-z\\(\\)]+)')
var server = createServer(router)

route.all(sendParams)

request(server)
.get('/1234')
.expect(404, cb)

request(server)
.get('/foo')
.expect(200, { user: 'foo' }, cb)

request(server)
.get('/(foo)')
.expect(200, { user: '(foo)' }, cb)
})

it('should work within arrays', function (done) {
var cb = after(2, done)
var router = new Router()
Expand Down

0 comments on commit 9c4e973

Please sign in to comment.