From f8f99789e4fd8bc948ff4e419816679d1d57bca4 Mon Sep 17 00:00:00 2001 From: Piotr Szala <136376248+szalapi@users.noreply.github.com> Date: Thu, 4 Jan 2024 15:21:54 +0100 Subject: [PATCH 1/2] Converting mime check to use lower case comparison --- src/js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/index.js b/src/js/index.js index 30d5e94..9c9b257 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -23,7 +23,7 @@ const plugin = ({ addFilter, utils }) => { } // is normal mime type - return acceptedType === userInputType; + return acceptedType.toLowerCase() === userInputType.toLowerCase(); }); const getItemType = (item) => { From 9365c671e4f48ae2e07ef0a79145a59611be551d Mon Sep 17 00:00:00 2001 From: Piotr Szala <136376248+szalapi@users.noreply.github.com> Date: Fri, 5 Jan 2024 15:00:50 +0100 Subject: [PATCH 2/2] Fix MIME checking --- src/js/index.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/js/index.js b/src/js/index.js index 9c9b257..1dbff8a 100644 --- a/src/js/index.js +++ b/src/js/index.js @@ -15,16 +15,20 @@ const plugin = ({ addFilter, utils }) => { return mimeTypeGroup === wildcardGroup; }; - const isValidMimeType = (acceptedTypes, userInputType) => + const isValidMimeType = (acceptedTypes, userInputType) => { + + // MIME is case insesitive, so we make sure to compare lower case only + const userInputTypeLowerCased = userInputType.toLowerCase(); acceptedTypes.some(acceptedType => { // accepted is wildcard mime type if (/\*$/.test(acceptedType)) { - return mimeTypeMatchesWildCard(userInputType, acceptedType); + return mimeTypeMatchesWildCard(userInputTypeLowerCased, acceptedType); } // is normal mime type - return acceptedType.toLowerCase() === userInputType.toLowerCase(); + return acceptedType.toLowerCase() === userInputTypeLowerCased; }); + } const getItemType = (item) => {