Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum committed Nov 12, 2024
1 parent 80cfbc1 commit 8c1de3b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,11 @@
* 2.0.
*/

export const SUPPORTED_FILE_TYPES = ['text/csv', 'text/plain', 'text/tab-separated-values', '.tsv'];
export const SUPPORTED_FILE_TYPES = [
'text/csv',
'text/plain',
'text/tab-separated-values',
'.tsv', // Useful for Windows when it can't recognise the file extension.
'.csv', // Useful for Windows when it can't recognise the file extension.
];
export const SUPPORTED_FILE_EXTENSIONS = ['CSV', 'TXT', 'TSV'];
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ export const validateFile = (
file: File,
formatBytes: (bytes: number) => string
): { valid: false; errorMessage: string; code: string } | { valid: true } => {
if (file.type !== '' && !SUPPORTED_FILE_TYPES.includes(file.type)) {
if (
file.type !== '' && // file.type might be an empty string on windows
!SUPPORTED_FILE_TYPES.includes(file.type)
) {
return {
valid: false,
code: 'unsupported_file_type',
Expand Down

0 comments on commit 8c1de3b

Please sign in to comment.