Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix: XML body disappearing with invalid XML (#3567)
Akash Kee1425d0dd78
diff --git a/packages/hoppscotch-common/src/composables/codemirror.ts b/packages/hoppscotch-common/src/composables/codemirror.tsindex 3c1f06ef4..3babd3686 100644--- a/packages/hoppscotch-common/src/composables/codemirror.ts+++ b/packages/hoppscotch-common/src/composables/codemirror.ts@@ -44,6 +44,8 @@ import { invokeAction } from "~/helpers/actions"import { useDebounceFn } from "@vueuse/core"// TODO: Migrate from legacy mode+import * as E from "fp-ts/Either"+type ExtendedEditorConfig = {mode: stringplaceholder: string@@ -160,6 +162,21 @@ const getLanguage = (langMime: string): Language | null => {return null}+const formatXML = (doc: string) => {+ try {+ const formatted = xmlFormat(doc, {+ indentation: " ",+ collapseContent: true,+ lineSeparator: "\n",+ whiteSpaceAtEndOfSelfclosingTag: true,+ })++ return E.right(formatted)+ } catch (e) {+ return E.left(e)+ }+}+/*** Uses xml-formatter to format the XML document* @param doc Document to parse@@ -171,14 +188,11 @@ const parseDoc = (langMime: string): string | undefined => {if (langMime === "application/xml" && doc) {- return xmlFormat(doc, {- indentation: " ",- collapseContent: true,- lineSeparator: "\n",- })- } else {- return doc+ const xmlFormatingResult = formatXML(doc)+ if (E.isRight(xmlFormatingResult)) return xmlFormatingResult.right}++ return doc}const getEditorLanguage = (