Skip to content

Commit

Permalink
support */* value for accepts prop
Browse files Browse the repository at this point in the history
  • Loading branch information
asabhaney committed Feb 1, 2022
1 parent e6f4a46 commit 2da3184
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/fileTypeAcceptable.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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
}
Expand Down

0 comments on commit 2da3184

Please sign in to comment.