filter: cleanup path separator conversion

This commit is contained in:
Michael Eischer 2020-10-07 21:14:07 +02:00
parent 0acc3c5923
commit 8388e67c4b

View file

@ -24,21 +24,13 @@ func prepareStr(str string) ([]string, error) {
return nil, ErrBadString
}
// convert file path separator to '/'
if filepath.Separator != '/' {
str = strings.Replace(str, string(filepath.Separator), "/", -1)
}
str = filepath.ToSlash(str)
return strings.Split(str, "/"), nil
}
func preparePattern(pattern string) Pattern {
pattern = filepath.Clean(pattern)
// convert file path separator to '/'
if filepath.Separator != '/' {
pattern = strings.Replace(pattern, string(filepath.Separator), "/", -1)
}
pattern = filepath.ToSlash(pattern)
parts := strings.Split(pattern, "/")
patterns := make([]patternPart, len(parts))