Throw TypeError for missing root argument
This commit is contained in:
@@ -70,11 +70,12 @@ var mediaType = {
|
||||
* @api public
|
||||
*/
|
||||
|
||||
exports = module.exports = function directory(root, options){
|
||||
exports = module.exports = function serveIndex(root, options){
|
||||
options = options || {};
|
||||
|
||||
// root required
|
||||
if (!root) throw new Error('directory() root path required');
|
||||
if (!root) throw new TypeError('serveIndex() root path required');
|
||||
|
||||
var hidden = options.hidden
|
||||
, icons = options.icons
|
||||
, view = options.view || 'tiles'
|
||||
@@ -83,7 +84,7 @@ exports = module.exports = function directory(root, options){
|
||||
, template = options.template || defaultTemplate
|
||||
, stylesheet = options.stylesheet || defaultStylesheet;
|
||||
|
||||
return function directory(req, res, next) {
|
||||
return function serveIndex(req, res, next) {
|
||||
if ('GET' != req.method && 'HEAD' != req.method) return next();
|
||||
|
||||
var url = parse(req.url)
|
||||
|
||||
+5
-1
@@ -4,7 +4,11 @@ var request = require('supertest');
|
||||
var should = require('should');
|
||||
var serveIndex = require('..');
|
||||
|
||||
describe('directory()', function(){
|
||||
describe('serveIndex(root)', function () {
|
||||
it('should require root', function () {
|
||||
serveIndex.should.throw(/root path required/)
|
||||
})
|
||||
|
||||
describe('when given Accept: header', function () {
|
||||
describe('when Accept: application/json is given', function () {
|
||||
it('should respond with json', function (done) {
|
||||
|
||||
Reference in New Issue
Block a user