From 4e7785c6207e2c1504333f50c69e41bb491d2740 Mon Sep 17 00:00:00 2001 From: Douglas Christopher Wilson Date: Thu, 1 Apr 2021 16:40:42 -0400 Subject: [PATCH] Fix icons for MIME types with "+" fixes #99 --- HISTORY.md | 1 + index.js | 2 +- test/fixtures/collect/sample.svg | 0 test/test.js | 1 + 4 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/collect/sample.svg diff --git a/HISTORY.md b/HISTORY.md index 593919e..bbdb0c7 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,7 @@ unreleased ========== + * Fix icons for MIME types with `+` * Fix text and json responses to match html sorting * Show font icon for more font types * Use 400 error on URI decode failure instead of 500 diff --git a/index.js b/index.js index 09086ac..e95390e 100644 --- a/index.js +++ b/index.js @@ -416,7 +416,7 @@ function iconLookup(filename) { // try by mime type if (icons[mimetype]) { return { - className: 'icon-' + mimetype.replace('/', '-'), + className: 'icon-' + mimetype.replace('/', '-').replace('+', '_'), fileName: icons[mimetype] }; } diff --git a/test/fixtures/collect/sample.svg b/test/fixtures/collect/sample.svg new file mode 100644 index 0000000..e69de29 diff --git a/test/test.js b/test/test.js index e5a5270..c1509a4 100644 --- a/test/test.js +++ b/test/test.js @@ -386,6 +386,7 @@ describe('serveIndex(root)', function () { .expect(/icon-default/) .expect(/icon-directory/) .expect(/icon-image/) + .expect(/icon-image-svg_xml/) .expect(/icon-txt/) .expect(/icon-application-pdf/) .expect(/icon-video/)