diff --git a/infra/conf/common.go b/infra/conf/common.go index 543c0746a45c..6b12d586c060 100644 --- a/infra/conf/common.go +++ b/infra/conf/common.go @@ -272,7 +272,13 @@ func (v *Int32Range) UnmarshalJSON(data []byte) error { return nil } // for range value, like "114-514" - pair := strings.SplitN(str, "-", 2) + var pair []string + // Process sth like "-114-514" "-1919--810" + if strings.HasPrefix(str, "-") { + pair = splitFromSecondDash(str) + } else { + pair = strings.SplitN(str, "-", 2) + } if len(pair) == 2 { left, err := strconv.Atoi(pair[0]) right, err2 := strconv.Atoi(pair[1]) @@ -298,3 +304,13 @@ func (r *Int32Range) ensureOrder() { r.From, r.To = r.To, r.From } } + +// "-114-514" → ["114","-514"] +// "-1919--810" → ["-1919","-810"] +func splitFromSecondDash(s string) []string { + parts := strings.SplitN(s, "-", 3) + if len(parts) < 3 { + return []string{s} + } + return []string{parts[0] + "-" + parts[1], parts[2]} +}