fix: mov files not being allowed on video upload (#792)

This commit is contained in:
Kristin Aoki
2024-01-11 12:19:09 -05:00
committed by GitHub
parent 433a87795c
commit bfcd3e6ff9
2 changed files with 16 additions and 3 deletions

View File

@@ -110,11 +110,19 @@ export const getSupportedFormats = (supportedFileFormats) => {
let format;
if (isArray(value)) {
value.forEach(val => {
format = key.replace('*', val.substring(1));
if (val === '.mov') {
format = key.replace('*', 'quicktime');
} else {
format = key.replace('*', val.substring(1));
}
supportedFormats.push(format);
});
} else {
format = key.replace('*', value?.substring(1));
if (value === '.mov') {
format = key.replace('*', 'quicktime');
} else {
format = key.replace('*', value.substring(1));
}
supportedFormats.push(format);
}
});

View File

@@ -23,8 +23,13 @@ describe('getSupportedFormats', () => {
const actual = getSupportedFormats({ 'image/*': '.png' });
expect(expected).toEqual(actual);
});
it('should return video/quicktime for .mov', () => {
const expected = ['video/quicktime'];
const actual = getSupportedFormats({ 'video/*': '.mov' });
expect(expected).toEqual(actual);
});
it('should return array of valid file types', () => {
const expected = ['video/mp4', 'video/mov'];
const expected = ['video/mp4', 'video/quicktime'];
const actual = getSupportedFormats({ 'video/*': ['.mp4', '.mov'] });
expect(expected).toEqual(actual);
});