From e9576dd33962d675978be6e5461f9303b811abae Mon Sep 17 00:00:00 2001 From: Andrew Bastin Date: Thu, 28 Jul 2022 17:38:31 +0530 Subject: [PATCH 1/2] fix: ignore confirm save modal on same request selection even when no session --- .../hoppscotch-app/components/collections/my/Request.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/hoppscotch-app/components/collections/my/Request.vue b/packages/hoppscotch-app/components/collections/my/Request.vue index 0c633f4c6..eca0a947a 100644 --- a/packages/hoppscotch-app/components/collections/my/Request.vue +++ b/packages/hoppscotch-app/components/collections/my/Request.vue @@ -339,7 +339,14 @@ const selectRequest = () => { confirmChange.value = false setRestReq(props.request) } else if (!active.value) { - confirmChange.value = true + // If the current request is the same as the request to be loaded in, there is no data loss + const currentReq = getRESTRequest() + + if (isEqualHoppRESTRequest(currentReq, props.request)) { + setRestReq(props.request) + } else { + confirmChange.value = true + } } else { const currentReqWithNoChange = active.value.req const currentFullReq = getRESTRequest() From fa0e7f4785e8fe0535a3a9a274bf0144d1f0749b Mon Sep 17 00:00:00 2001 From: kyteinsky Date: Thu, 28 Jul 2022 21:03:05 +0530 Subject: [PATCH 2/2] fix: curl parser x-www-form-urlencoded body parsing (#2528) --- .../helpers/curl/__tests__/curlparser.spec.js | 31 +++++++++++++++++++ .../hoppscotch-app/helpers/curl/curlparser.ts | 3 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/packages/hoppscotch-app/helpers/curl/__tests__/curlparser.spec.js b/packages/hoppscotch-app/helpers/curl/__tests__/curlparser.spec.js index 0d649a2cf..7b3b8352c 100644 --- a/packages/hoppscotch-app/helpers/curl/__tests__/curlparser.spec.js +++ b/packages/hoppscotch-app/helpers/curl/__tests__/curlparser.spec.js @@ -809,6 +809,37 @@ const samples = [ testScript: "", }), }, + { + command: `curl https://example.com -d "alpha=beta&request_id=4"`, + response: makeRESTRequest({ + method: "POST", + name: "Untitled request", + endpoint: "https://example.com/", + auth: { + authType: "none", + authActive: true, + }, + body: { + contentType: "application/x-www-form-urlencoded", + body: rawKeyValueEntriesToString([ + { + active: true, + key: "alpha", + value: "beta", + }, + { + active: true, + key: "request_id", + value: "4", + }, + ]), + }, + params: [], + headers: [], + preRequestScript: "", + testScript: "", + }), + }, ] describe("Parse curl command to Hopp REST Request", () => { diff --git a/packages/hoppscotch-app/helpers/curl/curlparser.ts b/packages/hoppscotch-app/helpers/curl/curlparser.ts index 21b0b48b1..27f2ef223 100644 --- a/packages/hoppscotch-app/helpers/curl/curlparser.ts +++ b/packages/hoppscotch-app/helpers/curl/curlparser.ts @@ -93,7 +93,8 @@ export const parseCurlCommand = (curlCommand: string) => { hasBodyBeenParsed = true } else if ( rawContentType.includes("application/x-www-form-urlencoded") && - !!pairs + !!pairs && + Array.isArray(rawData) ) { body = pairs.map((p) => p.join(": ")).join("\n") || null contentType = "application/x-www-form-urlencoded"