Update rules/rules.go

Use `strings.HasPrefix` to avoid panic on empty string.

Co-authored-by: Oleg Lobanov <oleg@lobanov.me>
This commit is contained in:
Tiger Nie 2020-11-18 22:36:43 +08:00 committed by GitHub
parent 0aa85e09f0
commit 324113a0fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -22,7 +22,7 @@ type Rule struct {
// MatchHidden matches paths with a basename
// that begins with a dot.
func MatchHidden(path string) bool {
return filepath.Base(path)[0] == '.'
return strings.HasPrefix(filepath.Base(path), ".")
}
// Matches matches a path against a rule.