Skip to content

Commit 22c8d60

Browse files
authored
Merge pull request #250 from open-source-labs/sam/render-html
render html responses
2 parents ed26693 + f60169d commit 22c8d60

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@
138138
"classnames": "^2.2.6",
139139
"date-fns": "^1.29.0",
140140
"dexie": "^2.0.4",
141+
"dompurify": "^2.0.3",
141142
"electron-devtools-installer": "^2.2.4",
142143
"electron-log": "^2.2.17",
143144
"electron-updater": "^4.0.5",

src/client/components/display/ResponseEventsDisplay.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import SSERow from './SSERow.jsx';
33
import JSONPretty from 'react-json-pretty';
4-
4+
import createDOMPurify from 'dompurify';
55

66
const ResponseEventsDisplay = ({ response }) => {
77
const { events, headers } = response;
@@ -13,6 +13,12 @@ const ResponseEventsDisplay = ({ response }) => {
1313
displayContents.push(<SSERow key={idx} content={cur} />);
1414
});
1515
}
16+
// if the response content-type, purify and render html
17+
else if (headers && headers['content-type'] && headers['content-type'].includes('text/html')) {
18+
displayContents.push(
19+
<div className="okay" dangerouslySetInnerHTML={{__html: createDOMPurify.sanitize(events[0])}} />
20+
)
21+
}
1622
// Otherwise, render a single display
1723
else {
1824
if (events) {

0 commit comments

Comments
 (0)