diff --git a/parse.go b/parse.go index 55ea356..4a930a4 100644 --- a/parse.go +++ b/parse.go @@ -108,7 +108,7 @@ func ParseFile(f io.Reader, options ...parseOption) (Ruleset, error) { lineNo := 0 for scanner.Scan() { lineNo++ - line := scanner.Text() + line := strings.TrimSpace(scanner.Text()) // Ignore blank lines and comments if len(line) == 0 || line[0] == '#' { diff --git a/parse_test.go b/parse_test.go index b16d6e1..f45a17e 100644 --- a/parse_test.go +++ b/parse_test.go @@ -47,6 +47,22 @@ func TestParseFile(t *testing.T) { }, }, }, + { + name: "with blank lines with whitespace", + contents: "\nfile.txt @user\n \t\nfile2.txt @org/team\n", + expected: Ruleset{ + { + pattern: mustBuildPattern(t, "file.txt"), + Owners: []Owner{{Value: "user", Type: "username"}}, + LineNumber: 2, + }, + { + pattern: mustBuildPattern(t, "file2.txt"), + Owners: []Owner{{Value: "org/team", Type: "team"}}, + LineNumber: 4, + }, + }, + }, // Error cases {