Merge pull request #838 from Joschasa/feature/always-indent-json-in-queryresult

Feature/always indent json in queryresult
This commit is contained in:
Anoop M D 2023-12-07 01:01:11 +05:30 committed by GitHub
commit 9f8dba0fb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -39,7 +39,7 @@ const formatResponse = (data, mode, filter) => {
return safeStringifyJSON(parsed, true);
}
if (['text', 'html'].includes(mode) || typeof data === 'string') {
if (typeof data === 'string') {
return data;
}
@ -48,7 +48,7 @@ const formatResponse = (data, mode, filter) => {
const QueryResult = ({ item, collection, data, dataBuffer, width, disableRunEventListener, headers, error }) => {
const contentType = getContentType(headers);
const mode = getCodeMirrorModeBasedOnContentType(contentType);
const mode = getCodeMirrorModeBasedOnContentType(contentType, data);
const [filter, setFilter] = useState(null);
const formattedData = formatResponse(data, mode, filter);
const { storedTheme } = useTheme();

View File

@ -42,7 +42,10 @@ export const defineCodeMirrorBrunoVariablesMode = (variables, mode) => {
});
};
export const getCodeMirrorModeBasedOnContentType = (contentType) => {
export const getCodeMirrorModeBasedOnContentType = (contentType, body) => {
if (typeof body === 'object') {
return 'application/ld+json';
}
if (!contentType || typeof contentType !== 'string') {
return 'application/text';
}