Use the body to check for a json content type

This commit is contained in:
André Glüpker 2023-11-01 16:24:38 +01:00
parent 76a26b634d
commit dc32d7246c
2 changed files with 5 additions and 2 deletions

View File

@ -37,7 +37,7 @@ const formatResponse = (data, mode) => {
const QueryResult = ({ item, collection, data, dataBuffer, width, disableRunEventListener, headers, error }) => {
const contentType = getContentType(headers);
const mode = getCodeMirrorModeBasedOnContentType(contentType);
const mode = getCodeMirrorModeBasedOnContentType(contentType, data);
const formattedData = formatResponse(data, mode);
const { storedTheme } = useTheme();

View File

@ -43,7 +43,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';
}