mirror of https://github.com/status-im/go-waku.git
fix: use stdbase64 encoding
This commit is contained in:
parent
042521e00b
commit
f41055778c
|
@ -14,11 +14,8 @@ type MessagesReply = []*RPCWakuMessage
|
|||
|
||||
type Base64URLByte []byte
|
||||
|
||||
func (u Base64URLByte) MarshalJSON() ([]byte, error) {
|
||||
base64Value := base64.URLEncoding.EncodeToString(u)
|
||||
return []byte("\"" + base64Value + "\""), nil
|
||||
}
|
||||
|
||||
// UnmarshalText is used by json.Unmarshal to decode both url-safe and standard
|
||||
// base64 encoded strings with and without padding
|
||||
func (h *Base64URLByte) UnmarshalText(b []byte) error {
|
||||
inputValue := ""
|
||||
if b != nil {
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestBase64Encoding(t *testing.T) {
|
|||
m := make(map[string]interface{})
|
||||
err = json.Unmarshal(jsonBytes, &m)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, base64.URLEncoding.EncodeToString([]byte(input)), m["payload"])
|
||||
require.Equal(t, base64.StdEncoding.EncodeToString([]byte(input)), m["payload"])
|
||||
|
||||
decodedRpcMsg := new(RPCWakuMessage)
|
||||
err = json.Unmarshal(jsonBytes, decodedRpcMsg)
|
||||
|
|
Loading…
Reference in New Issue