From f0b547232bdb4b175edac137f943b03c40c405bd Mon Sep 17 00:00:00 2001 From: techncl Date: Thu, 5 Dec 2024 09:53:30 +0000 Subject: [PATCH] Make drag and drop extension matching is case insensitive --- .../nationalarchives/csv/validator/ui/CsvValidatorUi.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala b/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala index 2066f503..b45de3e0 100644 --- a/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala +++ b/csv-validator-ui/src/main/scala/uk/gov/nationalarchives/csv/validator/ui/CsvValidatorUi.scala @@ -262,7 +262,7 @@ object CsvValidatorUi extends SimpleSwingApplication { val numOfFilesDropped = files.length lazy val filePaths = files.map(_.getAbsolutePath) lazy val (file1Ext, file2Ext) = { - val fileExtensions = filePaths.map(_.split('.').last) + val fileExtensions = filePaths.map(_.split('.').last.toLowerCase) (fileExtensions.head, fileExtensions.last) } @@ -270,11 +270,12 @@ object CsvValidatorUi extends SimpleSwingApplication { else if (numOfFilesDropped == 2 && Set(file1Ext, file2Ext) != Set("csv", "csvs")) showErrorDialog("Drop a single '.csv' file and its corresponding '.csvs' file.") else filePaths.map { filePath => - if(filePath.endsWith(".csv")) { + val lowercasedFilePath = filePath.toLowerCase + if(lowercasedFilePath.endsWith(".csv")) { txtCsvFile.setText(filePath) true } - else if(filePath.endsWith(".csvs")) { + else if(lowercasedFilePath.endsWith(".csvs")) { txtCsvSchemaFile.setText(filePath) true }