From 324113a0fe42e60a8bf7917c3bf7a1985a7c76e4 Mon Sep 17 00:00:00 2001 From: Tiger Nie Date: Wed, 18 Nov 2020 22:36:43 +0800 Subject: [PATCH] Update rules/rules.go Use `strings.HasPrefix` to avoid panic on empty string. Co-authored-by: Oleg Lobanov --- rules/rules.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules/rules.go b/rules/rules.go index 5fe2fb8a..d8a7f967 100644 --- a/rules/rules.go +++ b/rules/rules.go @@ -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.