Skip to content

Commit

Permalink
Fix rule-set format
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed Oct 19, 2024
1 parent 93dfc30 commit 0b42f26
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions option/rule_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,6 @@ func (r *RuleSet) UnmarshalJSON(bytes []byte) error {
if r.Tag == "" {
return E.New("missing tag")
}
if r.Type != C.RuleSetTypeInline {
switch r.Format {
case "":
return E.New("missing format")
case C.RuleSetFormatSource, C.RuleSetFormatBinary:
default:
return E.New("unknown rule-set format: " + r.Format)
}
} else {
r.Format = ""
}
var v any
switch r.Type {
case "", C.RuleSetTypeInline:
Expand All @@ -71,6 +60,17 @@ func (r *RuleSet) UnmarshalJSON(bytes []byte) error {
default:
return E.New("unknown rule-set type: " + r.Type)
}
if r.Type != C.RuleSetTypeInline {
switch r.Format {
case "":
return E.New("missing format")
case C.RuleSetFormatSource, C.RuleSetFormatBinary:
default:
return E.New("unknown rule-set format: " + r.Format)
}
} else {
r.Format = ""
}
err = UnmarshallExcluded(bytes, (*_RuleSet)(r), v)
if err != nil {
return err
Expand Down

0 comments on commit 0b42f26

Please sign in to comment.