Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ func isAlphanumeric(ch rune) bool {
// isPatternChar matches characters that are allowed in patterns
func isPatternChar(ch rune) bool {
switch ch {
case '*', '?', '.', '/', '@', '_', '+', '-', '\\', '(', ')':
case '*', '?', '.', '/', '@', '_', '+', '-', '\\', '(', ')', '|', '{', '}':
return true
}
return isAlphanumeric(ch)
Expand Down
45 changes: 40 additions & 5 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,53 @@ func TestParseRule(t *testing.T) {
Comment: "",
},
},
{
name: "pattern with pipe character '|'",
rule: "foo|bar|baz @org/team",
expected: Rule{
pattern: mustBuildPattern(t, "foo|bar|baz"),
Owners: []Owner{{Value: "org/team", Type: "team"}},
},
},
{
name: "pattern with left curly brace '{'",
rule: "foo{bar.txt @org/team",
expected: Rule{
pattern: mustBuildPattern(t, "foo{bar.txt"),
Owners: []Owner{{Value: "org/team", Type: "team"}},
},
},
{
name: "pattern with right curly brace '}'",
rule: "foo}bar.txt @org/team",
expected: Rule{
pattern: mustBuildPattern(t, "foo}bar.txt"),
Owners: []Owner{{Value: "org/team", Type: "team"}},
},
},
{
name: "pattern with curly braces '{' and '}'",
rule: "foo{bar}.txt @org/team",
expected: Rule{
pattern: mustBuildPattern(t, "foo{bar}.txt"),
Owners: []Owner{{Value: "org/team", Type: "team"}},
},
},
{
name: "pattern with curly braces and pipe character",
rule: "foo|{bar}.txt @org/team",
expected: Rule{
pattern: mustBuildPattern(t, "foo|{bar}.txt"),
Owners: []Owner{{Value: "org/team", Type: "team"}},
},
},

// Error cases
{
name: "empty rule",
rule: "",
err: "unexpected end of rule",
},
{
name: "malformed patterns",
rule: "file.{txt @user",
err: "unexpected character '{' at position 6",
},
{
name: "patterns with brackets",
rule: "file.[cC] @user",
Expand Down