diff --git a/pkg/optimization/optimization.go b/pkg/optimization/optimization.go index a9dd7818..5e8b50d2 100644 --- a/pkg/optimization/optimization.go +++ b/pkg/optimization/optimization.go @@ -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 @@ -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()