From 70c38d9aa75969efd3b9b1243fc5ff8ba5a847c2 Mon Sep 17 00:00:00 2001 From: Lykin <137850705+tiny-craft@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:46:50 +0800 Subject: [PATCH] fix: can not display correct content with decoder after modified --- backend/services/browser_service.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/backend/services/browser_service.go b/backend/services/browser_service.go index eb65d45..71e6baa 100644 --- a/backend/services/browser_service.go +++ b/backend/services/browser_service.go @@ -1241,7 +1241,7 @@ func (b *browserService) SetKeyValue(param types.SetKeyParam) (resp types.JSResp if len(param.Format) <= 0 { param.Format = types.FORMAT_RAW } - var savedValue any + var savedValue string switch strings.ToLower(param.KeyType) { case "string": if str, ok := param.Value.(string); !ok { @@ -1339,7 +1339,10 @@ func (b *browserService) SetKeyValue(param types.SetKeyParam) (resp types.JSResp if err == nil && expiration > 0 { client.Expire(ctx, key, expiration) } - savedValue = param.Value + var ok bool + if savedValue, ok = param.Value.(string); !ok { + savedValue = "" + } } if err != nil { @@ -1348,7 +1351,7 @@ func (b *browserService) SetKeyValue(param types.SetKeyParam) (resp types.JSResp } resp.Success = true resp.Data = map[string]any{ - "value": savedValue, + "value": strutil.EncodeRedisKey(savedValue), } return }