From 4372e85bb3082d38681f95bbd328223f66b7cbb6 Mon Sep 17 00:00:00 2001 From: Tara Vancil Date: Sat, 5 Nov 2016 14:00:53 -0400 Subject: [PATCH 1/2] render correct icon for files with no extension --- bin/list | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/list b/bin/list index fadf5a7c..24a7a332 100644 --- a/bin/list +++ b/bin/list @@ -86,12 +86,13 @@ const renderDirectory = async dir => { const index = files.indexOf(file) const details = path.parse(filePath) - details.ext = details.ext.split('.')[1] details.relative = path.join(subPath, details.base) if (await isDir(filePath)) { details.base += '/' } else { + details.ext = details.ext.split('.')[1] || 'txt' + let fileStats try { From 5cc50744a41b108812c4257d342e28a9c7fab119 Mon Sep 17 00:00:00 2001 From: Tara Vancil Date: Sat, 5 Nov 2016 14:01:20 -0400 Subject: [PATCH 2/2] serve files with no extension instead of 404ing --- bin/list | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/bin/list b/bin/list index 24a7a332..2f825486 100644 --- a/bin/list +++ b/bin/list @@ -185,13 +185,9 @@ const handler = async (req, res) => { } // Check if file or directory path - if (path.parse(related).ext === '') { + if (await isDir(related)) { let indexPath = path.join(related, '/index.html') - if (!await isDir(related) && flags.single === undefined) { - return send(res, 404, notFoundResponse) - } - res.setHeader('Content-Type', mime.contentType(path.extname(indexPath))) if (!fs.existsSync(indexPath)) {