Return 404's.
This commit is contained in:
parent
c2669360d1
commit
a09e208b0a
|
@ -57,13 +57,7 @@ exports.minifyJS = function(req, res, next)
|
||||||
} else {
|
} else {
|
||||||
// Not in tar list, but try anyways, if it fails, pass to `next`.
|
// Not in tar list, but try anyways, if it fails, pass to `next`.
|
||||||
jsFiles = [jsFilename];
|
jsFiles = [jsFilename];
|
||||||
fs.stat(JS_DIR + jsFilename, function (error, stats) {
|
_handle(req, res, jsFilename, jsFiles);
|
||||||
if (error || !stats.isFile()) {
|
|
||||||
next();
|
|
||||||
} else {
|
|
||||||
_handle(req, res, jsFilename, jsFiles);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,14 +69,29 @@ function _handle(req, res, jsFilename, jsFiles) {
|
||||||
res.setHeader('last-modified', date.toUTCString());
|
res.setHeader('last-modified', date.toUTCString());
|
||||||
res.setHeader('date', (new Date()).toUTCString());
|
res.setHeader('date', (new Date()).toUTCString());
|
||||||
|
|
||||||
if (new Date(req.headers['if-modified-since']) >= date) {
|
fs.stat(JS_DIR + jsFiles[0], function (error, stats) {
|
||||||
res.writeHead(304, {});
|
if (error) {
|
||||||
res.end();
|
if (error.code == "ENOENT") {
|
||||||
} else if (settings.minify) {
|
res.writeHead(404, {});
|
||||||
respondMinified();
|
res.end();
|
||||||
} else {
|
} else {
|
||||||
respondRaw();
|
res.writeHead(500, {});
|
||||||
}
|
res.end();
|
||||||
|
}
|
||||||
|
} else if (!stats.isFile()) {
|
||||||
|
res.writeHead(404, {});
|
||||||
|
res.end();
|
||||||
|
} else if (new Date(req.headers['if-modified-since']) >= date) {
|
||||||
|
res.writeHead(304, {});
|
||||||
|
res.end();
|
||||||
|
} else {
|
||||||
|
if (settings.minify) {
|
||||||
|
respondMinified();
|
||||||
|
} else {
|
||||||
|
respondRaw();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function respondMinified()
|
function respondMinified()
|
||||||
|
|
Loading…
Reference in New Issue