Merge PR #1260: Fixed url encoding issue
This commit is contained in:
parent
e4685ecba5
commit
f68e903d06
|
@ -321,8 +321,9 @@ func TestTxs(t *testing.T) {
|
|||
assert.Equal(t, 1, len(indexedTxs))
|
||||
|
||||
// query sender
|
||||
// also tests url decoding
|
||||
addrBech := sdk.MustBech32ifyAcc(addr)
|
||||
res, body = Request(t, port, "GET", fmt.Sprintf("/txs?tag=sender_bech32='%s'", addrBech), nil)
|
||||
res, body = Request(t, port, "GET", "/txs?tag=sender_bech32=%27"+addrBech+"%27", nil)
|
||||
require.Equal(t, http.StatusOK, res.StatusCode, body)
|
||||
|
||||
err = cdc.UnmarshalJSON([]byte(body), &indexedTxs)
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -107,7 +108,12 @@ func SearchTxRequestHandlerFn(ctx context.CoreContext, cdc *wire.Codec) http.Han
|
|||
}
|
||||
keyValue := strings.Split(tag, "=")
|
||||
key := keyValue[0]
|
||||
value := keyValue[1]
|
||||
value, err := url.QueryUnescape(keyValue[1])
|
||||
if err != nil {
|
||||
w.WriteHeader(400)
|
||||
w.Write([]byte("Could not decode address: " + err.Error()))
|
||||
return
|
||||
}
|
||||
if strings.HasSuffix(key, "_bech32") {
|
||||
bech32address := strings.Trim(value, "'")
|
||||
prefix := strings.Split(bech32address, "1")[0]
|
||||
|
|
Loading…
Reference in New Issue