Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function setETag(req, res, next) {
const parsedUrl = url.parse(req.url);
let { pathname } = parsedUrl;
if (pathname === '/') {
pathname = '/index.html';
}
if (
exists(path.join(serverPath, pathname))
) {
res.setHeader('ETag', `"${sha1File(path.join(serverPath, pathname))}"`);
}
if (parentServerPath &&
exists(path.join(parentServerPath, pathname))) {
res.setHeader('ETag', `"${sha1File(path.join(parentServerPath, pathname))}"`);
}
next();
}