From b591b4ebdf23aa657fc01d48f7c01a5bbfa8452d Mon Sep 17 00:00:00 2001 From: Nekohy Date: Sat, 16 Aug 2025 11:58:40 +0800 Subject: [PATCH] fix:moveValue bug --- relay/common/override.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/relay/common/override.go b/relay/common/override.go index 83e62bf9..1508f2cd 100644 --- a/relay/common/override.go +++ b/relay/common/override.go @@ -198,7 +198,7 @@ func applyOperations(jsonStr string, operations []ParamOperation) (string, error } result, err = sjson.Set(result, op.Path, op.Value) case "move": - result, err = moveValue(result, op.From, op.To, op.KeepOrigin) + result, err = moveValue(result, op.From, op.To) case "prepend": result, err = modifyValue(result, op.Path, op.Value, op.KeepOrigin, true) case "append": @@ -213,14 +213,11 @@ func applyOperations(jsonStr string, operations []ParamOperation) (string, error return result, nil } -func moveValue(jsonStr, fromPath, toPath string, keepOrigin bool) (string, error) { +func moveValue(jsonStr, fromPath, toPath string) (string, error) { sourceValue := gjson.Get(jsonStr, fromPath) if !sourceValue.Exists() { return jsonStr, fmt.Errorf("source path does not exist: %s", fromPath) } - if keepOrigin && gjson.Get(jsonStr, toPath).Exists() { - return sjson.Delete(jsonStr, fromPath) - } result, err := sjson.Set(jsonStr, toPath, sourceValue.Value()) if err != nil { return "", err