Skip to content

Commit

Permalink
#131 fix missing query params on relative path request (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevatkm authored Mar 1, 2018
1 parent e008fe0 commit 3db9436
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func parseRequestURL(c *Client, r *Request) error {
// If Request.Url is relative path then added c.HostUrl into
// the request URL otherwise Request.Url will be used as-is
if !reqURL.IsAbs() {
reqURL, err = url.Parse(c.HostURL + reqURL.Path)
reqURL, err = url.Parse(c.HostURL + reqURL.String())
if err != nil {
return err
}
Expand Down Expand Up @@ -65,10 +65,12 @@ func parseRequestURL(c *Client, r *Request) error {
// Since not feasible in `SetQuery*` resty methods, because
// standard package `url.Encode(...)` sorts the query params
// alphabetically
if IsStringEmpty(reqURL.RawQuery) {
reqURL.RawQuery = query.Encode()
} else {
reqURL.RawQuery = reqURL.RawQuery + "&" + query.Encode()
if len(query) > 0 {
if IsStringEmpty(reqURL.RawQuery) {
reqURL.RawQuery = query.Encode()
} else {
reqURL.RawQuery = reqURL.RawQuery + "&" + query.Encode()
}
}

r.URL = reqURL.String()
Expand Down

0 comments on commit 3db9436

Please sign in to comment.