Skip to content

Commit

Permalink
fix query build bug
Browse files Browse the repository at this point in the history
  • Loading branch information
gotoxu committed Nov 23, 2017
1 parent c46556b commit 6920493
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions hmac_v1_sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ func (ctx *signingCtx) buildCanonicalString() {
uri = ctx.URL.EscapedPath()
}

ctx.URL.RawQuery = strings.Replace(ctx.Query.Encode(), "+", "%20", -1)
ctx.canonicalString = strings.Join([]string{
ctx.Method,
uri,
Expand Down
4 changes: 2 additions & 2 deletions hmac_v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func TestValidator(t *testing.T) {

func TestSignGetRequest(t *testing.T) {
values := url.Values{}
values.Set("id", "uuid")
values.Set("type", "Topic")
values.Set("type", "uuid")
values.Set("id", "Topic")

req := buildGetRequest(values)
signer := buildSigner()
Expand Down
1 change: 1 addition & 0 deletions hmac_v1_verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ func (ctx *verifyCtx) buildCanonicalString() {
uri = ctx.URL.EscapedPath()
}

ctx.URL.RawQuery = ctx.Query.Encode()
ctx.canonicalString = strings.Join([]string{
ctx.Method,
uri,
Expand Down

0 comments on commit 6920493

Please sign in to comment.