Skip to content

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

Removed redundant HTML response type check for preview code

Andrew Bastind31da4a0ecba
diff --git a/components/lenses/renderers/HTMLLensRenderer.vue b/components/lenses/renderers/HTMLLensRenderer.vue
index dc050b0a7..20438ce43 100644
--- a/components/lenses/renderers/HTMLLensRenderer.vue
+++ b/components/lenses/renderers/HTMLLensRenderer.vue
@@ -151,23 +151,18 @@ export default {
togglePreview() {
this.previewEnabled = !this.previewEnabled
if (this.previewEnabled) {
- // If you want to add 'preview' support for other response types,
- // just add them here.
- if (this.responseType === "text/html") {
- // If the preview already has that URL loaded, let's not bother re-loading it all.
- if (this.$refs.previewFrame.getAttribute("data-previewing-url") === this.url) return
- // Use DOMParser to parse document HTML.
- const previewDocument = new DOMParser().parseFromString(
- this.responseBodyText,
- this.responseType
- )
- // Inject <base href="..."> tag to head, to fix relative CSS/HTML paths.
- previewDocument.head.innerHTML =
- `<base href="${this.url}">` + previewDocument.head.innerHTML
- // Finally, set the iframe source to the resulting HTML.
- this.$refs.previewFrame.srcdoc = previewDocument.documentElement.outerHTML
- this.$refs.previewFrame.setAttribute("data-previewing-url", this.url)
- }
+ if (this.$refs.previewFrame.getAttribute("data-previewing-url") === this.url) return
+ // Use DOMParser to parse document HTML.
+ const previewDocument = new DOMParser().parseFromString(
+ this.responseBodyText,
+ this.responseType
+ )
+ // Inject <base href="..."> tag to head, to fix relative CSS/HTML paths.
+ previewDocument.head.innerHTML =
+ `<base href="${this.url}">` + previewDocument.head.innerHTML
+ // Finally, set the iframe source to the resulting HTML.
+ this.$refs.previewFrame.srcdoc = previewDocument.documentElement.outerHTML
+ this.$refs.previewFrame.setAttribute("data-previewing-url", this.url)
}
},
},