From 721044c1ae40b6959d379042cb8ef55485505ef3 Mon Sep 17 00:00:00 2001 From: gurukiran07 Date: Mon, 28 Oct 2024 13:08:09 -0300 Subject: [PATCH 1/3] Fix: yml is valid type --- cmd/validator/validator.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmd/validator/validator.go b/cmd/validator/validator.go index a3c1c9d..daa53a6 100644 --- a/cmd/validator/validator.go +++ b/cmd/validator/validator.go @@ -71,7 +71,9 @@ func validatorUsage() { func getFileTypes() []string { options := make([]string, 0, len(filetype.FileTypes)) for _, typ := range filetype.FileTypes { - options = append(options, typ.Name) + for extName := range typ.Extensions { + options = append(options, extName) + } } sort.Strings(options) return options From 029aa8caa008066c174a3de0389e0b72e2e6290f Mon Sep 17 00:00:00 2001 From: gurukiran07 Date: Tue, 29 Oct 2024 12:23:25 -0300 Subject: [PATCH 2/3] Make file extension matching case-insensitive --- cmd/validator/validator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/validator/validator.go b/cmd/validator/validator.go index daa53a6..9661942 100644 --- a/cmd/validator/validator.go +++ b/cmd/validator/validator.go @@ -86,7 +86,7 @@ func validateFileTypeList(input []string) bool { if len(t) == 0 { continue } - if !slices.Contains(types, t) { + if !slices.Contains(types, strings.ToLower(t)) { return false } } From f3282906e840ab049152e737515b2b41a046fe92 Mon Sep 17 00:00:00 2001 From: gurukiran07 Date: Tue, 29 Oct 2024 18:20:11 -0300 Subject: [PATCH 3/3] make exclude-file-types string lowercase before using it --- cmd/validator/validator.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/validator/validator.go b/cmd/validator/validator.go index 9661942..9dbdcb8 100644 --- a/cmd/validator/validator.go +++ b/cmd/validator/validator.go @@ -86,7 +86,7 @@ func validateFileTypeList(input []string) bool { if len(t) == 0 { continue } - if !slices.Contains(types, strings.ToLower(t)) { + if !slices.Contains(types, t) { return false } } @@ -157,6 +157,7 @@ func getFlags() (validatorConfig, error) { } if *excludeFileTypesPtr != "" { + *excludeFileTypesPtr = strings.ToLower(*excludeFileTypesPtr) if !validateFileTypeList(strings.Split(*excludeFileTypesPtr, ",")) { return validatorConfig{}, errors.New("Invalid exclude file type") }