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: ensure correct parser for xml and plaintext (#5597)
jaeyonglee-intaed032391f84
diff --git a/packages/hoppscotch-common/src/components.d.ts b/packages/hoppscotch-common/src/components.d.tsindex 54bff8780..d0329b81c 100644--- a/packages/hoppscotch-common/src/components.d.ts+++ b/packages/hoppscotch-common/src/components.d.ts@@ -1,8 +1,11 @@/* eslint-disable */// @ts-nocheck+// biome-ignore lint: disable+// oxlint-disable+// ------// Generated by unplugin-vue-components// Read more: https://github.com/vuejs/core/pull/3399-// biome-ignore lint: disable+export {}/* prettier-ignore */diff --git a/packages/hoppscotch-common/src/components/http/RawBody.vue b/packages/hoppscotch-common/src/components/http/RawBody.vueindex 70ff21dd5..9cb5179aa 100644--- a/packages/hoppscotch-common/src/components/http/RawBody.vue+++ b/packages/hoppscotch-common/src/components/http/RawBody.vue@@ -35,6 +35,7 @@'application/hal+json','application/vnd.api+json','application/xml',+ 'text/xml',].includes(body.contentType)"v-tippy="{ theme: 'tooltip' }"@@ -209,7 +210,10 @@ const prettifyRequestBody = () => {try {if (body.value.contentType.endsWith("json")) {prettifyBody = prettifyJSONC(rawParamsBody.value as string)- } else if (body.value.contentType === "application/xml") {+ } else if (+ body.value.contentType === "application/xml" ||+ body.value.contentType === "text/xml"+ ) {prettifyBody = prettifyXML(rawParamsBody.value as string)}rawParamsBody.value = prettifyBodydiff --git a/packages/hoppscotch-common/src/helpers/__tests__/editorutils.spec.js b/packages/hoppscotch-common/src/helpers/__tests__/editorutils.spec.jsindex 0bd5dac4f..f23636f40 100644--- a/packages/hoppscotch-common/src/helpers/__tests__/editorutils.spec.js+++ b/packages/hoppscotch-common/src/helpers/__tests__/editorutils.spec.js@@ -10,22 +10,23 @@ describe("getEditorLangForMimeType", () => {test("returns 'xml' for valid XML mimes", () => {expect(getEditorLangForMimeType("application/xml")).toMatch("xml")+ expect(getEditorLangForMimeType("text/xml")).toMatch("xml")})test("returns 'html' for valid HTML mimes", () => {expect(getEditorLangForMimeType("text/html")).toMatch("html")})- test("returns 'text/x-yaml' for plain text mime", () => {- expect(getEditorLangForMimeType("text/plain")).toMatch("text/x-yaml")+ test("returns text/plain for plain text mime", () => {+ expect(getEditorLangForMimeType("text/plain")).toBe("text/plain")})- test("returns 'text/x-yaml' for unimplemented mimes", () => {- expect(getEditorLangForMimeType("image/gif")).toMatch("text/x-yaml")+ test("returns text/plain for unimplemented mimes", () => {+ expect(getEditorLangForMimeType("image/gif")).toBe("text/plain")})- test("returns 'text/x-yaml' for null/undefined mimes", () => {- expect(getEditorLangForMimeType(null)).toMatch("text/x-yaml")- expect(getEditorLangForMimeType(undefined)).toMatch("text/x-yaml")+ test("returns text/plain for null/undefined mimes", () => {+ expect(getEditorLangForMimeType(null)).toBe("text/plain")+ expect(getEditorLangForMimeType(undefined)).toBe("text/plain")})})diff --git a/packages/hoppscotch-common/src/helpers/editorutils.ts b/packages/hoppscotch-common/src/helpers/editorutils.tsindex 733021337..72e1e7798 100644--- a/packages/hoppscotch-common/src/helpers/editorutils.ts+++ b/packages/hoppscotch-common/src/helpers/editorutils.ts@@ -1,5 +1,6 @@const mimeToMode = {- "text/plain": "text/x-yaml",+ "text/plain": "text/plain",+ "text/xml": "application/xml","text/html": "htmlmixed","application/xml": "application/xml","application/hal+json": "application/ld+json",@@ -8,5 +9,5 @@ const mimeToMode = {}export function getEditorLangForMimeType(mimeType: string): string {- return mimeToMode[mimeType] || "text/x-yaml"+ return mimeToMode[mimeType] || "text/plain"}