Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function formatDir(route, dirPath, entries) {
const parent = path.dirname(dirPath) || '/';
// Maintain path sep, but deal with things like spaces in filenames
const url = encodeURI(route + parent);
const header = `
<title>Index of ${dirPath}</title>
<h1>Index of ${dirPath}</h1>
`;
const footer = `<table><tbody><tr><th><img alt="[ICO]" src="${blank}"></th>
<th><b>Name</b></th><th><b>Last modified</b></th>
<th><b>Size</b></th><th><b>Description</b></th></tr>
<tr><th colspan="5"><hr></th></tr>
<tr><td valign="top"><img alt="[DIR]" src="${back}"></td>
<td><a href="${url}">Parent Directory</a></td><td> </td>
<td align="right"> - </td><td> </td></tr><tr><th colspan="5"><hr></th></tr></tbody></table>${footerClose}`;
const rows = entries.map(entry => {