Skip to content

Commit f1fe393

Browse files
committed
Assert the root path is a string
closes #16
1 parent affa215 commit f1fe393

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ exports = module.exports = function serveStatic(root, options) {
2929
throw new TypeError('root path required')
3030
}
3131

32+
if (typeof root !== 'string') {
33+
throw new TypeError('root path must be a string')
34+
}
35+
3236
// copy options object
3337
options = merge({}, options)
3438

test/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ describe('serveStatic()', function(){
2020
serveStatic.bind().should.throw(/root path required/);
2121
});
2222

23+
it('should require root path to be string', function(){
24+
serveStatic.bind(null, 42).should.throw(/root path.*string/);
25+
});
26+
2327
it('should serve static files', function(done){
2428
request(server)
2529
.get('/todo.txt')

0 commit comments

Comments
 (0)