Skip to content

Commit c39f0e4

Browse files
committedMay 8, 2019
golf(sirv): use return directly
1 parent b2e1baf commit c39f0e4

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed
 

‎packages/sirv/index.js

+8-9
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ function toAssume(uri, extns) {
2525
function find(uri, extns) {
2626
let i=0, data, arr=toAssume(uri, extns);
2727
for (; i < arr.length; i++) {
28-
if (data=FILES[arr[i]]) break;
28+
if (data = FILES[arr[i]]) return data;
2929
}
30-
return data;
3130
}
3231

3332
function is404(req, res) {
@@ -84,15 +83,15 @@ module.exports = function (dir, opts={}) {
8483
while (file = arr.shift()) {
8584
stats = fs.statSync(file);
8685
if (stats.isDirectory()) continue;
87-
setHeaders(res, uri, stats);
88-
send(req, res, file, stats, {
89-
'Content-Type': mime.getType(file),
90-
'Last-Modified': stats.mtime.toUTCString(),
91-
'Content-Length': stats.size,
92-
});
86+
setHeaders(res, uri, stats);
87+
send(req, res, file, stats, {
88+
'Content-Type': mime.getType(file),
89+
'Last-Modified': stats.mtime.toUTCString(),
90+
'Content-Length': stats.size,
91+
});
92+
}
9393
}
9494
}
95-
}
9695

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

0 commit comments

Comments
 (0)
Please sign in to comment.