MCPcopy Create free account
hub / github.com/testing-library/user-event / isAcceptableFile

Function isAcceptableFile

src/upload.ts:86–102  ·  view source on GitHub ↗
(file: File, accept: string)

Source from the content-addressed store, hash-verified

84}
85
86function isAcceptableFile(file: File, accept: string) {
87 if (!accept) {
88 return true
89 }
90
91 const wildcards = ['audio/*', 'image/*', 'video/*']
92
93 return accept.split(',').some(acceptToken => {
94 if (acceptToken.startsWith('.')) {
95 // tokens starting with a dot represent a file extension
96 return file.name.endsWith(acceptToken)
97 } else if (wildcards.includes(acceptToken)) {
98 return file.type.startsWith(acceptToken.substr(0, acceptToken.length - 1))
99 }
100 return file.type === acceptToken
101 })
102}
103
104export {upload}

Callers 1

uploadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected