mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
XML Indenting with header check
This commit is contained in:
parent
45ca5ded96
commit
ad905d1a0a
@ -34,5 +34,8 @@
|
||||
},
|
||||
"overrides": {
|
||||
"rollup": "3.2.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"xml-formatter": "^3.3.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import find from 'lodash/find';
|
||||
import classnames from 'classnames';
|
||||
import { safeStringifyJSON } from 'utils/common';
|
||||
import { formatResponse } from 'utils/common';
|
||||
import { useSelector, useDispatch } from 'react-redux';
|
||||
import { updateResponsePaneTab } from 'providers/ReduxStore/slices/tabs';
|
||||
import QueryResult from './QueryResult';
|
||||
@ -16,6 +16,7 @@ import TestResults from './TestResults';
|
||||
import TestResultsLabel from './TestResultsLabel';
|
||||
import StyledWrapper from './StyledWrapper';
|
||||
|
||||
|
||||
const ResponsePane = ({ rightPaneWidth, item, collection }) => {
|
||||
const dispatch = useDispatch();
|
||||
const tabs = useSelector((state) => state.tabs.tabs);
|
||||
@ -40,7 +41,7 @@ const ResponsePane = ({ rightPaneWidth, item, collection }) => {
|
||||
item={item}
|
||||
collection={collection}
|
||||
width={rightPaneWidth}
|
||||
value={response.data ? safeStringifyJSON(response.data, true) : ''}
|
||||
value={response.data ? formatResponse(response): ''}
|
||||
/>;
|
||||
}
|
||||
case 'headers': {
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { customAlphabet } from 'nanoid';
|
||||
import xmlFormat from 'xml-formatter';
|
||||
|
||||
// a customized version of nanoid without using _ and -
|
||||
export const uuid = () => {
|
||||
@ -50,6 +51,16 @@ export const safeStringifyJSON = (obj, indent=false) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const formatResponse = (response) => {
|
||||
var type = response.headers.find((element) => element[0]=='content-type')[1];
|
||||
if(type.includes("json")){
|
||||
return safeStringifyJSON(response.data);
|
||||
}if(type.includes("xml")){
|
||||
return xmlFormat(response.data, {collapseContent: true});
|
||||
}
|
||||
return response.data;
|
||||
}
|
||||
|
||||
// Remove any characters that are not alphanumeric, spaces, hyphens, or underscores
|
||||
export const normalizeFileName = (name) => {
|
||||
if (!name) {
|
||||
|
Loading…
Reference in New Issue
Block a user