diff --git a/editorconfig/path_matcher.go b/editorconfig/path_matcher.go index e373fb1..ccc953c 100644 --- a/editorconfig/path_matcher.go +++ b/editorconfig/path_matcher.go @@ -30,6 +30,13 @@ var metaCharsRegexp = []*regexp.Regexp{ } func ConvertWildcardPatternToGoRegexp(pattern string) *regexp.Regexp { + if pattern == "*" { + // A single * seems to be universally used to mean every file, despite the official docs + // showing that ** is correct and * should only match top-level files. However, we adapt + // to what is used in the real world to be practical. + return regexp.MustCompile(".") + } + originalPattern := pattern for _, r := range metaCharsRegexp { diff --git a/editorconfig/path_matcher_test.go b/editorconfig/path_matcher_test.go index 87ddbcc..6e0f8b5 100644 --- a/editorconfig/path_matcher_test.go +++ b/editorconfig/path_matcher_test.go @@ -43,4 +43,7 @@ func TestConvertWildcardPatternToGoRegexp(t *testing.T) { // Test everything together. RunConvertWildcardPatternToGoRegexp(`*/**/[a-z]/{photos,videos}/{0..5}.*`, `[^/\\]+/.+/[a-z]/(photos|videos)/[-0-9]+\.[^/\\]+`) + + // Test * on it's own. It should match every path. + RunConvertWildcardPatternToGoRegexp(`*`, `.`) }