From 8215f02fecb4aadfb2f40f795d019d9c51c65bf3 Mon Sep 17 00:00:00 2001 From: Nuno Cruces Date: Wed, 7 Jun 2023 14:22:07 +0100 Subject: [PATCH] Fix #63. --- file.go | 4 ++-- file_filter_test.go | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/file.go b/file.go index 869b49c..3b74fa4 100644 --- a/file.go +++ b/file.go @@ -182,8 +182,8 @@ func (f FileFilters) types() []string { if res == nil { return nil } - // Workaround for macOS bug: first type cannot be a four letter extension, so prepend empty string. - return append([]string{""}, res...) + // Workaround for macOS bug: first type cannot be a four letter extension, so prepend dot string. + return append([]string{"."}, res...) } // Unix patterns are case-sensitive. Fold them if requested. diff --git a/file_filter_test.go b/file_filter_test.go index fc5ed4c..102fe75 100644 --- a/file_filter_test.go +++ b/file_filter_test.go @@ -91,21 +91,21 @@ func TestFileFilters_types(t *testing.T) { want []string }{ {[]string{``}, nil}, - {[]string{`*.png`}, []string{"", "png"}}, + {[]string{`*.png`}, []string{".", "png"}}, {[]string{`*.pn?`}, nil}, - {[]string{`*.pn;`}, []string{"", "pn;"}}, - {[]string{`*.pn\?`}, []string{"", "pn?"}}, + {[]string{`*.pn;`}, []string{".", "pn;"}}, + {[]string{`*.pn\?`}, []string{".", "pn?"}}, {[]string{`*.[PpNnGg]`}, nil}, - {[]string{`*.[Pp][Nn][Gg]`}, []string{"", "PNG"}}, - {[]string{`*.[Pp][\Nn][G\g]`}, []string{"", "PNG"}}, - {[]string{`*.[PNG`}, []string{"", "[PNG"}}, - {[]string{`*.]PNG`}, []string{"", "]PNG"}}, - {[]string{`*.[[]PNG`}, []string{"", "[PNG"}}, - {[]string{`*.[]]PNG`}, []string{"", "]PNG"}}, - {[]string{`*.[\[]PNG`}, []string{"", "[PNG"}}, - {[]string{`*.[\]]PNG`}, []string{"", "]PNG"}}, - {[]string{`public.png`}, []string{"", "public.png"}}, - {[]string{`-public-.png`}, []string{"", "png"}}, + {[]string{`*.[Pp][Nn][Gg]`}, []string{".", "PNG"}}, + {[]string{`*.[Pp][\Nn][G\g]`}, []string{".", "PNG"}}, + {[]string{`*.[PNG`}, []string{".", "[PNG"}}, + {[]string{`*.]PNG`}, []string{".", "]PNG"}}, + {[]string{`*.[[]PNG`}, []string{".", "[PNG"}}, + {[]string{`*.[]]PNG`}, []string{".", "]PNG"}}, + {[]string{`*.[\[]PNG`}, []string{".", "[PNG"}}, + {[]string{`*.[\]]PNG`}, []string{".", "]PNG"}}, + {[]string{`public.png`}, []string{".", "public.png"}}, + {[]string{`-public-.png`}, []string{".", "png"}}, } for i, tt := range tests { filters := FileFilters{FileFilter{Patterns: tt.data}}