From c35a85db12d35f8413b263362280f45efbdbd37b Mon Sep 17 00:00:00 2001 From: Damanpreet Singh Date: Fri, 7 Oct 2022 02:29:15 +0530 Subject: [PATCH] fix: allow posting empty key files in multipart/form-data (#2664) --- .../hoppscotch-app/src/components/http/BodyParameters.vue | 4 ++-- packages/hoppscotch-app/src/helpers/utils/EffectiveURL.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/hoppscotch-app/src/components/http/BodyParameters.vue b/packages/hoppscotch-app/src/components/http/BodyParameters.vue index 26c7367bc..11b9c3a4c 100644 --- a/packages/hoppscotch-app/src/components/http/BodyParameters.vue +++ b/packages/hoppscotch-app/src/components/http/BodyParameters.vue @@ -250,7 +250,7 @@ watch( workingParams.value, A.filterMap( flow( - O.fromPredicate((e) => e.entry.key !== ""), + O.fromPredicate((e) => e.entry.key !== "" || e.entry.isFile), O.map((e) => e.entry) ) ) @@ -271,7 +271,7 @@ watch(workingParams, (newWorkingParams) => { newWorkingParams, A.filterMap( flow( - O.fromPredicate((e) => e.entry.key !== ""), + O.fromPredicate((e) => e.entry.key !== "" || e.entry.isFile), O.map((e) => e.entry) ) ) diff --git a/packages/hoppscotch-app/src/helpers/utils/EffectiveURL.ts b/packages/hoppscotch-app/src/helpers/utils/EffectiveURL.ts index 50564fea0..73966016f 100644 --- a/packages/hoppscotch-app/src/helpers/utils/EffectiveURL.ts +++ b/packages/hoppscotch-app/src/helpers/utils/EffectiveURL.ts @@ -254,7 +254,7 @@ function getFinalBodyFromRequest( if (request.body.contentType === "multipart/form-data") { return pipe( request.body.body, - A.filter((x) => x.key !== "" && x.active), // Remove empty keys + A.filter((x) => (x.key !== "" || x.isFile) && x.active), // Remove empty keys // Sort files down arraySort((a, b) => {