Skip to content

Commit e4b7cc3

Browse files
committedApr 15, 2019
fix: run setHeaders within dev mode
- Closes #22
1 parent a76c7b7 commit e4b7cc3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed
 

‎packages/sirv/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,17 @@ module.exports = function (dir, opts={}) {
7676

7777
let isNotFound = opts.onNoMatch || is404;
7878
let extensions = opts.extensions || ['html', 'htm'];
79+
let setHeaders = opts.setHeaders || noop;
7980

8081
if (opts.dev) {
8182
return function (req, res, next) {
82-
let [start=0, end=Infinity] = (req.headers.range || '').replace('bytes=', '').split('-');
8383
let uri = decodeURIComponent(req.path || req.pathname || parser(req).pathname);
8484
let arr = uri.includes('.') ? [uri] : toAssume(uri, extensions);
8585
let file = arr.map(x => join(dir, x)).find(fs.existsSync);
8686
if (!file) return next ? next() : isNotFound(res);
8787

8888
let stats = fs.statSync(file);
89+
setHeaders(res, uri, stats);
8990
send(req, res, file, stats, {
9091
'Content-Type': mime.getType(file),
9192
'Last-Modified': stats.mtime.toUTCString(),
@@ -94,7 +95,6 @@ module.exports = function (dir, opts={}) {
9495
}
9596
}
9697

97-
let setHeaders = opts.setHeaders || noop;
9898
let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`;
9999
if (cc && opts.immutable) cc += ',immutable';
100100

0 commit comments

Comments
 (0)
Please sign in to comment.