From 2da3184b003b966c808cc893ade6ae71ed29001c Mon Sep 17 00:00:00 2001 From: Ajay Sabhaney Date: Mon, 31 Jan 2022 19:12:51 -0500 Subject: [PATCH] support */* value for accepts prop --- src/utils/fileTypeAcceptable.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils/fileTypeAcceptable.js b/src/utils/fileTypeAcceptable.js index 4dbd23a..3663bb6 100644 --- a/src/utils/fileTypeAcceptable.js +++ b/src/utils/fileTypeAcceptable.js @@ -1,7 +1,5 @@ -// TODO: SUPPORT */* -// See: https://github.com/mother/react-files/issues/27 // eslint-disable-next-line -const mimeTypeRegexp = /^(application|audio|example|image|message|model|multipart|text|video)\/[a-z0-9\.\+\*-]+$/ +const mimeTypeRegexp = /^(application|audio|example|image|message|model|multipart|text|video|\*)\/[a-z0-9\.\+\*-]+$/ const extRegexp = /\.[a-zA-Z0-9]*$/ const fileTypeAcceptable = (accepts, file) => { @@ -15,6 +13,10 @@ const fileTypeAcceptable = (accepts, file) => { const [acceptLeft, acceptRight] = accept.split('/') if (acceptLeft && acceptRight) { + if (acceptLeft === '*' && acceptRight === '*') { + return true + } + if (acceptLeft === typeLeft && acceptRight === '*') { return true }