File tree Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Expand file tree Collapse file tree 2 files changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ type RuleCondition struct {
12
12
13
13
func (c RuleCondition ) MarshalJSON () ([]byte , error ) {
14
14
m := make (map [string ]interface {})
15
- if c .Anchoring != "" || c . Pattern != "" {
15
+ if c .Anchoring != "" {
16
16
m ["anchoring" ] = c .Anchoring
17
17
m ["pattern" ] = c .Pattern
18
18
}
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ func TestRuleCondition_MarshalJSON(t *testing.T) {
44
44
Alternatives : nil ,
45
45
Filters : "" ,
46
46
},
47
- `{"anchoring": "", "pattern": "Pattern" }` ,
47
+ `{}` ,
48
48
},
49
49
{
50
50
RuleCondition {
@@ -106,7 +106,11 @@ func TestRuleCondition_MarshalJSON(t *testing.T) {
106
106
107
107
// Compare the two RuleConditions
108
108
require .Equal (t , c .condition .Anchoring , condition .Anchoring )
109
- require .Equal (t , c .condition .Pattern , condition .Pattern )
109
+ if c .condition .Anchoring == "" {
110
+ require .Equal (t , condition .Pattern , "" )
111
+ } else {
112
+ require .Equal (t , c .condition .Pattern , condition .Pattern )
113
+ }
110
114
require .Equal (t , c .condition .Context , condition .Context )
111
115
if c .condition .Alternatives == nil {
112
116
require .Nil (t , condition .Alternatives )
You can’t perform that action at this time.
0 commit comments