Skip to content

Commit

Permalink
fix: default index could be disabled
Browse files Browse the repository at this point in the history
closes #41
  • Loading branch information
haoxin committed Nov 3, 2015
1 parent 20df2c7 commit 79e1c16
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -33,7 +33,7 @@ function serve(root, opts) {
// options
debug('static "%s" %j', root, opts);
opts.root = resolve(root);
opts.index = opts.index || 'index.html';
if (opts.index !== false) opts.index = opts.index || 'index.html';

if (!opts.defer) {
return function *serve(next){
Expand Down
12 changes: 12 additions & 0 deletions test/index.js
Expand Up @@ -90,6 +90,18 @@ describe('serve(root)', function(){
.expect('html index', done);
})
})

describe('when disabled', function(){
it('should use index.html', function(done){
const app = koa();

app.use(serve('test/fixtures', { index: false }));

request(app.listen())
.get('/world/')
.expect(404, done);
})
})
})

describe('when method is not `GET` or `HEAD`', function(){
Expand Down

0 comments on commit 79e1c16

Please sign in to comment.