diff --git a/cmd/testdata/example.js b/cmd/testdata/example.js index cd4be5f0cb2..e8c132fbf99 100644 --- a/cmd/testdata/example.js +++ b/cmd/testdata/example.js @@ -56,9 +56,10 @@ export default function() { } ) if (!check(res, {"status is 201": (r) => r.status === 201 })) { return }; + redirectUrl = res.headers.Location; json = JSON.parse(res.body); // Request #1 - res = http.get("https://some-host.example.com/checkout/v3/orders/570714bf-3c2b-452e-90cd-f7c5e552bb25", + res = http.get(redirectUrl, { "headers": { "Authorization": "Basic stuffz", diff --git a/converter/har/converter.go b/converter/har/converter.go index 49361c4ad05..cc0d516375d 100644 --- a/converter/har/converter.go +++ b/converter/har/converter.go @@ -103,7 +103,6 @@ func Convert(h HAR, enableChecks bool, returnOnFailedCheck bool, batchTime uint, if nobatch { var recordedRedirectURL string - var recordedRestID string previousResponse := map[string]interface{}{} fmt.Fprint(w, "\t\tlet res, redirectUrl, json;\n") @@ -140,11 +139,7 @@ func Convert(h HAR, enableChecks bool, returnOnFailedCheck bool, batchTime uint, fmt.Fprintf(w, "redirectUrl") recordedRedirectURL = "" } else { - if recordedRestID != "" && strings.Contains(e.Request.URL, recordedRestID) { - fmt.Fprintf(w, "`%s`", strings.Replace(e.Request.URL, recordedRestID, "${restID}", -1)) - } else { - fmt.Fprintf(w, "%q", e.Request.URL) - } + fmt.Fprintf(w, "%q", e.Request.URL) } if e.Request.Method != "GET" { @@ -191,6 +186,16 @@ func Convert(h HAR, enableChecks bool, returnOnFailedCheck bool, batchTime uint, } } + if e.Response.Headers != nil { + for _, header := range e.Response.Headers { + if header.Name == "Location" { + fmt.Fprintf(w, "\t\tredirectUrl = res.headers.Location;\n") + recordedRedirectURL = header.Value + break + } + } + } + responseMimeType := e.Response.Content.MimeType if correlate && strings.Index(responseMimeType, "application/") == 0 &&