Skip to content

Commit

Permalink
Merge pull request #121 from bp0lr/master
Browse files Browse the repository at this point in the history
fix bug on MakeRequestQuery
  • Loading branch information
hahwul authored Sep 28, 2020
2 parents 527cff1 + b159382 commit 64eb641
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pkg/optimization/optimization.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ func MakeRequestQuery(target, param, payload, ptype string, options model.Option

payload = url.QueryEscape(payload)
u, _ := url.Parse(target)

data := u.String()

if options.Data != "" {
tempParam, _ := url.ParseQuery(options.Data)
var body string
Expand All @@ -100,11 +102,22 @@ func MakeRequestQuery(target, param, payload, ptype string, options model.Option

} else {
tempParam := u.Query()
if tempParam[param] == nil {
data = "?" + param + "=" + payload + "&" + data

if tempParam[param] == nil {
if(strings.Contains(data, "?")) {
data = data + "&"+param+"="+payload
} else{
data = data + "?"+param+"="+payload
}
} else {
data = strings.Replace(data, param+"="+url.QueryEscape(tempParam[param][0]), param+"="+url.QueryEscape(tempParam[param][0])+payload, 1)
data = strings.Replace(data, param+"=" + url.QueryEscape(tempParam[param][0]), param + "=" + url.QueryEscape(tempParam[param][0])+payload, 1)
if tempParam[param] == nil {
data = "?" + param + "=" + payload + "&" + data
} else {
data = strings.Replace(data, param+"="+url.QueryEscape(tempParam[param][0]), param+"="+url.QueryEscape(tempParam[param][0])+payload, 1)
}
}

tempURL, _ := url.Parse(data)
tempQuery := tempURL.Query()
tempURL.RawQuery = tempQuery.Encode()
Expand Down

0 comments on commit 64eb641

Please sign in to comment.