Skip to content

Commit

Permalink
fix: mov files not being allowed on video upload (#792)
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinAoki authored Jan 11, 2024
1 parent 433a877 commit bfcd3e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/files-and-videos/videos-page/data/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down
7 changes: 6 additions & 1 deletion src/files-and-videos/videos-page/data/utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Expand Down

0 comments on commit bfcd3e6

Please sign in to comment.