File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ export default function(file, acceptedFiles) {
1414 const acceptedFilesArray = Array . isArray ( acceptedFiles )
1515 ? acceptedFiles
1616 : acceptedFiles . split ( ',' )
17+ if ( acceptedFilesArray . length === 0 ) {
18+ return true
19+ }
1720 const fileName = file . name || ''
1821 const mimeType = ( file . type || '' ) . toLowerCase ( )
1922 const baseMimeType = mimeType . replace ( / \/ .* $ / , '' )
Original file line number Diff line number Diff line change @@ -307,4 +307,25 @@ describe('accept', () => {
307307 )
308308 ) . toBe ( true )
309309 } )
310+
311+ it ( 'should allow any file if the accepted files is an empty array or string' , ( ) => {
312+ expect (
313+ accept (
314+ {
315+ name : 'testfile.jpg' ,
316+ type : 'img/jpeg'
317+ } ,
318+ ''
319+ )
320+ ) . toBe ( true )
321+ expect (
322+ accept (
323+ {
324+ name : 'testfile.pdf' ,
325+ type : 'random/type'
326+ } ,
327+ [ ]
328+ )
329+ ) . toBe ( true )
330+ } )
310331} )
You can’t perform that action at this time.
0 commit comments