1234567891011121314151617181920212223242526 |
- "use strict";
- exports.__esModule = true;
- exports.default = function (file, acceptedFiles) {
- if (file && acceptedFiles) {
- var acceptedFilesArray = Array.isArray(acceptedFiles) ? acceptedFiles : acceptedFiles.split(',');
- var fileName = file.name || '';
- var mimeType = (file.type || '').toLowerCase();
- var baseMimeType = mimeType.replace(/\/.*$/, '');
- return acceptedFilesArray.some(function (type) {
- var validType = type.trim().toLowerCase();
- if (validType.charAt(0) === '.') {
- return fileName.toLowerCase().endsWith(validType);
- } else if (validType.endsWith('/*')) {
- // This is something like a image/* mime type
- return baseMimeType === validType.replace(/\/.*$/, '');
- }
- return mimeType === validType;
- });
- }
- return true;
- };
|