Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix: allow posting empty key files in multipart/form-data (#2664)

Damanpreet Singhc35a85db12d3
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) => {