This commit is contained in:
Nuno Cruces 2023-06-07 14:22:07 +01:00
parent 8dceefd22c
commit 8215f02fec
2 changed files with 15 additions and 15 deletions

View file

@ -182,8 +182,8 @@ func (f FileFilters) types() []string {
if res == nil { if res == nil {
return nil return nil
} }
// Workaround for macOS bug: first type cannot be a four letter extension, so prepend empty string. // Workaround for macOS bug: first type cannot be a four letter extension, so prepend dot string.
return append([]string{""}, res...) return append([]string{"."}, res...)
} }
// Unix patterns are case-sensitive. Fold them if requested. // Unix patterns are case-sensitive. Fold them if requested.

View file

@ -91,21 +91,21 @@ func TestFileFilters_types(t *testing.T) {
want []string want []string
}{ }{
{[]string{``}, nil}, {[]string{``}, nil},
{[]string{`*.png`}, []string{"", "png"}}, {[]string{`*.png`}, []string{".", "png"}},
{[]string{`*.pn?`}, nil}, {[]string{`*.pn?`}, nil},
{[]string{`*.pn;`}, []string{"", "pn;"}}, {[]string{`*.pn;`}, []string{".", "pn;"}},
{[]string{`*.pn\?`}, []string{"", "pn?"}}, {[]string{`*.pn\?`}, []string{".", "pn?"}},
{[]string{`*.[PpNnGg]`}, nil}, {[]string{`*.[PpNnGg]`}, nil},
{[]string{`*.[Pp][Nn][Gg]`}, []string{"", "PNG"}}, {[]string{`*.[Pp][Nn][Gg]`}, []string{".", "PNG"}},
{[]string{`*.[Pp][\Nn][G\g]`}, []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{`*.[]]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{".", "public.png"}},
{[]string{`-public-.png`}, []string{"", "png"}}, {[]string{`-public-.png`}, []string{".", "png"}},
} }
for i, tt := range tests { for i, tt := range tests {
filters := FileFilters{FileFilter{Patterns: tt.data}} filters := FileFilters{FileFilter{Patterns: tt.data}}