Browse Source

feats:the error of gjson.True and gjson.False

Nekohy 6 months ago
parent
commit
5696a62c27
1 changed files with 6 additions and 0 deletions
  1. 6 0
      relay/common/override.go

+ 6 - 0
relay/common/override.go

@@ -202,6 +202,12 @@ func compareGjsonValues(jsonValue, targetValue gjson.Result, mode string) (bool,
 }
 
 func compareEqual(jsonValue, targetValue gjson.Result) (bool, error) {
+	// 对布尔值特殊处理
+	if (jsonValue.Type == gjson.True || jsonValue.Type == gjson.False) &&
+		(targetValue.Type == gjson.True || targetValue.Type == gjson.False) {
+		return jsonValue.Bool() == targetValue.Bool(), nil
+	}
+
 	// 如果类型不同,报错
 	if jsonValue.Type != targetValue.Type {
 		return false, fmt.Errorf("compare for different types, got %v and %v", jsonValue.Type, targetValue.Type)