From 8c1de3b550baa7c1bc1879232cf474a1254524b4 Mon Sep 17 00:00:00 2001 From: machadoum Date: Tue, 12 Nov 2024 14:45:36 +0100 Subject: [PATCH] Add comments --- .../asset_criticality_file_uploader/constants.ts | 8 +++++++- .../asset_criticality_file_uploader/validations.ts | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/constants.ts b/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/constants.ts index 9db2cf4f7c8d6..966068eb4c074 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/constants.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/constants.ts @@ -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']; diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/validations.ts b/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/validations.ts index 453b4b53f8df7..6f8bd8fb816bf 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/validations.ts +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/asset_criticality_file_uploader/validations.ts @@ -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',