Skip to content

Commit

Permalink
golf(sirv): use return directly
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed May 8, 2019
1 parent b2e1baf commit c39f0e4
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions packages/sirv/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ function toAssume(uri, extns) {
function find(uri, extns) {
let i=0, data, arr=toAssume(uri, extns);
for (; i < arr.length; i++) {
if (data=FILES[arr[i]]) break;
if (data = FILES[arr[i]]) return data;
}
return data;
}

function is404(req, res) {
Expand Down Expand Up @@ -84,15 +83,15 @@ module.exports = function (dir, opts={}) {
while (file = arr.shift()) {
stats = fs.statSync(file);
if (stats.isDirectory()) continue;
setHeaders(res, uri, stats);
send(req, res, file, stats, {
'Content-Type': mime.getType(file),
'Last-Modified': stats.mtime.toUTCString(),
'Content-Length': stats.size,
});
setHeaders(res, uri, stats);
send(req, res, file, stats, {
'Content-Type': mime.getType(file),
'Last-Modified': stats.mtime.toUTCString(),
'Content-Length': stats.size,
});
}
}
}
}

let cc = opts.maxAge != null && `public,max-age=${opts.maxAge}`;
if (cc && opts.immutable) cc += ',immutable';
Expand Down

0 comments on commit c39f0e4

Please sign in to comment.