From d83920c52e8277a51d9cc1b02e5a82357f4f2d4b Mon Sep 17 00:00:00 2001 From: bp0 Date: Mon, 28 Sep 2020 19:13:14 -0300 Subject: [PATCH 1/3] fix bug on MakeRequestQuery --- pkg/optimization/optimization.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pkg/optimization/optimization.go b/pkg/optimization/optimization.go index ce10cdd9..c1107828 100644 --- a/pkg/optimization/optimization.go +++ b/pkg/optimization/optimization.go @@ -83,7 +83,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 @@ -101,11 +103,18 @@ 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) } + + fmt.Printf("data: %v\n", data) + tempURL, _ := url.Parse(data) tempQuery := tempURL.Query() tempURL.RawQuery = tempQuery.Encode() From 86dd0573db8b084c806850842c6df3a45ab0b41d Mon Sep 17 00:00:00 2001 From: bp0 Date: Mon, 28 Sep 2020 19:22:15 -0300 Subject: [PATCH 2/3] delete debug log. --- pkg/optimization/optimization.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/optimization/optimization.go b/pkg/optimization/optimization.go index c1107828..c17d4489 100644 --- a/pkg/optimization/optimization.go +++ b/pkg/optimization/optimization.go @@ -113,8 +113,6 @@ func MakeRequestQuery(target, param, payload, ptype string, options model.Option data = strings.Replace(data, param+"=" + url.QueryEscape(tempParam[param][0]), param + "=" + url.QueryEscape(tempParam[param][0])+payload, 1) } - fmt.Printf("data: %v\n", data) - tempURL, _ := url.Parse(data) tempQuery := tempURL.Query() tempURL.RawQuery = tempQuery.Encode() From b1593828886fe5c6d07c1b5b7f45d307dcb91fca Mon Sep 17 00:00:00 2001 From: HAHWUL Date: Tue, 29 Sep 2020 08:51:54 +0900 Subject: [PATCH 3/3] Update optimization.go --- pkg/optimization/optimization.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/optimization/optimization.go b/pkg/optimization/optimization.go index 83d7e073..5e8b50d2 100644 --- a/pkg/optimization/optimization.go +++ b/pkg/optimization/optimization.go @@ -104,18 +104,18 @@ func MakeRequestQuery(target, param, payload, ptype string, options model.Option tempParam := u.Query() if tempParam[param] == nil { - if(strings.Contains(data, "?")){ + if(strings.Contains(data, "?")) { data = data + "&"+param+"="+payload - }else{ + } else{ data = data + "?"+param+"="+payload } } else { 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) + 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)