File filter tweaks.
This commit is contained in:
parent
8215f02fec
commit
b90dce112e
2 changed files with 8 additions and 6 deletions
12
file.go
12
file.go
|
@ -157,12 +157,14 @@ func (f FileFilters) types() []string {
|
||||||
res = append(res, pattern)
|
res = append(res, pattern)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
dot := strings.LastIndexByte(pattern, '.')
|
||||||
ext := pattern[strings.LastIndexByte(pattern, '.')+1:]
|
if dot < 0 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
var escape bool
|
var escape bool
|
||||||
var buf strings.Builder
|
var buf strings.Builder
|
||||||
for _, b := range []byte(removeClasses(ext)) {
|
for _, b := range []byte(removeClasses(pattern[dot+1:])) {
|
||||||
switch {
|
switch {
|
||||||
case escape:
|
case escape:
|
||||||
escape = false
|
escape = false
|
||||||
|
@ -174,9 +176,7 @@ func (f FileFilters) types() []string {
|
||||||
}
|
}
|
||||||
buf.WriteByte(b)
|
buf.WriteByte(b)
|
||||||
}
|
}
|
||||||
if buf.Len() > 0 {
|
res = append(res, buf.String())
|
||||||
res = append(res, buf.String())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if res == nil {
|
if res == nil {
|
||||||
|
|
|
@ -31,6 +31,7 @@ func TestFileFilters_simplify(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
{[]string{``}, nil},
|
{[]string{``}, nil},
|
||||||
{[]string{`*.\?`}, nil},
|
{[]string{`*.\?`}, nil},
|
||||||
|
{[]string{`*.`}, []string{`*.`}},
|
||||||
{[]string{`*.png`}, []string{"*.png"}},
|
{[]string{`*.png`}, []string{"*.png"}},
|
||||||
{[]string{`*.pn?`}, []string{"*.pn?"}},
|
{[]string{`*.pn?`}, []string{"*.pn?"}},
|
||||||
{[]string{`*.pn;`}, []string{"*.pn?"}},
|
{[]string{`*.pn;`}, []string{"*.pn?"}},
|
||||||
|
@ -91,6 +92,7 @@ func TestFileFilters_types(t *testing.T) {
|
||||||
want []string
|
want []string
|
||||||
}{
|
}{
|
||||||
{[]string{``}, nil},
|
{[]string{``}, nil},
|
||||||
|
{[]string{`*.`}, []string{".", ""}},
|
||||||
{[]string{`*.png`}, []string{".", "png"}},
|
{[]string{`*.png`}, []string{".", "png"}},
|
||||||
{[]string{`*.pn?`}, nil},
|
{[]string{`*.pn?`}, nil},
|
||||||
{[]string{`*.pn;`}, []string{".", "pn;"}},
|
{[]string{`*.pn;`}, []string{".", "pn;"}},
|
||||||
|
|
Loading…
Reference in a new issue