Skip to content

Commit

Permalink
permit leading and trailing whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
hmarr committed Jun 26, 2024
1 parent 477e3fd commit 06d1caa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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] == '#' {
Expand Down
16 changes: 16 additions & 0 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 06d1caa

Please sign in to comment.