From 9475a162f72c4d83c4e229568af8c983a32f793f Mon Sep 17 00:00:00 2001 From: liyasthomas Date: Mon, 24 Jan 2022 10:00:07 +0530 Subject: [PATCH] chore: clean up --- .../helpers/rules/BodyTransition.ts | 2 - .../hoppscotch-app/newstore/RESTSession.ts | 96 ------------------- 2 files changed, 98 deletions(-) diff --git a/packages/hoppscotch-app/helpers/rules/BodyTransition.ts b/packages/hoppscotch-app/helpers/rules/BodyTransition.ts index 13844e2ae..a6baef813 100644 --- a/packages/hoppscotch-app/helpers/rules/BodyTransition.ts +++ b/packages/hoppscotch-app/helpers/rules/BodyTransition.ts @@ -172,8 +172,6 @@ export const applyBodyTransition = ( current: HoppRESTReqBody, target: T ): HoppRESTReqBody & { contentType: T } => { - debugger - if (current.contentType === target) { console.warn( `Tried to transition body from and to the same content-type '${target}'` diff --git a/packages/hoppscotch-app/newstore/RESTSession.ts b/packages/hoppscotch-app/newstore/RESTSession.ts index e1186528c..10185ad67 100644 --- a/packages/hoppscotch-app/newstore/RESTSession.ts +++ b/packages/hoppscotch-app/newstore/RESTSession.ts @@ -204,7 +204,6 @@ const dispatchers = defineDispatchers({ curr: RESTSession, { newContentType }: { newContentType: ValidContentTypes | null } ) { - // TODO: Cleaner implementation // TODO: persist body evenafter switching content typees return { request: { @@ -212,101 +211,6 @@ const dispatchers = defineDispatchers({ body: applyBodyTransition(curr.request.body, newContentType), }, } - // if (curr.request.body.contentType !== "multipart/form-data") { - // if (newContentType === "multipart/form-data") { - // // Preserve entries when comping from urlencoded to multipart - // if ( - // curr.request.body.contentType === "application/x-www-form-urlencoded" - // ) { - // return { - // request: { - // ...curr.request, - // body: { - // contentType: "multipart/form-data", - // body: pipe( - // curr.request.body.body, - // parseRawKeyValueEntries, - // A.map( - // ({ key, value, active }) => - // { key, value, active, isFile: false } - // ) - // ), - // }, - // }, - // } - // } - - // // Going from non-formdata to form-data, discard contents and set empty array as body - // return { - // request: { - // ...curr.request, - // body: { - // contentType: "multipart/form-data", - // body: [], - // }, - // }, - // } - // } else { - // // non-formdata to non-formdata, keep body and set content type - // return { - // request: { - // ...curr.request, - // body: { - // contentType: newContentType, - // body: - // newContentType === null - // ? null - // : (curr.request.body as any)?.body ?? "", - // }, - // }, - // } - // } - // } else if (newContentType !== "multipart/form-data") { - // if (newContentType === "application/x-www-form-urlencoded") { - // return { - // request: { - // ...curr.request, - // body: { - // contentType: newContentType, - // body: pipe( - // curr.request.body.body, - // A.map( - // ({ key, value, isFile, active }) => - // { - // key, - // value: isFile ? "" : value, - // active, - // } - // ), - // rawKeyValueEntriesToString - // ), - // }, - // }, - // } - // } - - // // Going from formdata to non-formdata, discard contents and set empty string - // return { - // request: { - // ...curr.request, - // body: { - // contentType: newContentType, - // body: "", - // }, - // }, - // } - // } else { - // // form-data to form-data ? just set the content type ¯\_(ツ)_/¯ - // return { - // request: { - // ...curr.request, - // body: { - // contentType: newContentType, - // body: curr.request.body.body, - // }, - // }, - // } - // } }, addFormDataEntry(curr: RESTSession, { entry }: { entry: FormDataKeyValue }) { // Only perform update if the current content-type is formdata