Skip to content

Commit

Permalink
chore: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
liyasthomas committed Jan 24, 2022
1 parent ffe6596 commit 9475a16
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 98 deletions.
2 changes: 0 additions & 2 deletions packages/hoppscotch-app/helpers/rules/BodyTransition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,6 @@ export const applyBodyTransition = <T extends ValidContentTypes | null>(
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}'`
Expand Down
96 changes: 0 additions & 96 deletions packages/hoppscotch-app/newstore/RESTSession.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,109 +204,13 @@ const dispatchers = defineDispatchers({
curr: RESTSession,
{ newContentType }: { newContentType: ValidContentTypes | null }
) {
// TODO: Cleaner implementation
// TODO: persist body evenafter switching content typees
return {
request: {
...curr.request,
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: <HoppRESTReqBody>{
// contentType: "multipart/form-data",
// body: pipe(
// curr.request.body.body,
// parseRawKeyValueEntries,
// A.map(
// ({ key, value, active }) =>
// <FormDataKeyValue>{ 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: <HoppRESTReqBody>{
// contentType: "multipart/form-data",
// body: [],
// },
// },
// }
// } else {
// // non-formdata to non-formdata, keep body and set content type
// return {
// request: {
// ...curr.request,
// body: <HoppRESTReqBody>{
// 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: <HoppRESTReqBody>{
// contentType: newContentType,
// body: pipe(
// curr.request.body.body,
// A.map(
// ({ key, value, isFile, active }) =>
// <RawKeyValueEntry>{
// key,
// value: isFile ? "" : value,
// active,
// }
// ),
// rawKeyValueEntriesToString
// ),
// },
// },
// }
// }

// // Going from formdata to non-formdata, discard contents and set empty string
// return {
// request: {
// ...curr.request,
// body: <HoppRESTReqBody>{
// contentType: newContentType,
// body: "",
// },
// },
// }
// } else {
// // form-data to form-data ? just set the content type ¯\_(ツ)_/¯
// return {
// request: {
// ...curr.request,
// body: <HoppRESTReqBody>{
// contentType: newContentType,
// body: curr.request.body.body,
// },
// },
// }
// }
},
addFormDataEntry(curr: RESTSession, { entry }: { entry: FormDataKeyValue }) {
// Only perform update if the current content-type is formdata
Expand Down

0 comments on commit 9475a16

Please sign in to comment.