Skip to content

Commit 5c1a911

Browse files
author
Oleg Sucharevich
committed
fix bug - query string wasnt build correctly
1 parent 5c9b631 commit 5c1a911

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.2
1+
0.3.3

pkg/codefresh/codefresh.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io/ioutil"
88
"net/http"
9+
"strings"
910
)
1011

1112
type (
@@ -30,10 +31,7 @@ func (c *codefresh) requestAPI(opt *requestOptions) (*http.Response, error) {
3031
var body []byte
3132
finalURL := fmt.Sprintf("%s%s", c.host, opt.path)
3233
if opt.qs != nil {
33-
finalURL += "?"
34-
for k, v := range opt.qs {
35-
finalURL += fmt.Sprintf("%s=%s", k, v)
36-
}
34+
finalURL += toQS(opt.qs)
3735
}
3836
if opt.body != nil {
3937
body, _ = json.Marshal(opt.body)
@@ -49,6 +47,14 @@ func (c *codefresh) requestAPI(opt *requestOptions) (*http.Response, error) {
4947
return response, nil
5048
}
5149

50+
func toQS(qs map[string]string) string {
51+
var arr = []string{}
52+
for k, v := range qs {
53+
arr = append(arr, fmt.Sprintf("%s=%s", k, v))
54+
}
55+
return "?" + strings.Join(arr, "&")
56+
}
57+
5258
func (c *codefresh) decodeResponseInto(resp *http.Response, target interface{}) error {
5359
return json.NewDecoder(resp.Body).Decode(target)
5460
}

0 commit comments

Comments
 (0)