Skip to content

Commit

Permalink
Merge 724152c into e04c217
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Nov 13, 2015
2 parents e04c217 + 724152c commit d1cb653
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Router.prototype.handle = function handle(req, res, callback) {
next()

function next(err) {
var layerError = err === 'route'
var layerError = err === 'route' || err === 'router'
? null
: err

Expand All @@ -207,7 +207,7 @@ Router.prototype.handle = function handle(req, res, callback) {
}

// no more matching layers
if (idx >= stack.length) {
if (err === 'router' || idx >= stack.length) {
defer(done, layerError)
return
}
Expand Down
15 changes: 15 additions & 0 deletions test/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,21 @@ describe('Router', function () {
.expect(200, 'saw POST /foo', cb)
})

it('should exit the router', function (done) {
var router = new Router()
var server = createServer(router)

router.use(function (req, res, next) {
next('router')
})

router.use(helloWorld)

request(server)
.get('/')
.expect(404, done)
})

it('should not invoke for blank URLs', function (done) {
var router = new Router()
var server = createServer(function hander(req, res, next) {
Expand Down

0 comments on commit d1cb653

Please sign in to comment.