mirror of
https://github.com/Kong/insomnia
synced 2024-11-07 22:30:15 +00:00
Auto detect JSON and fix editor crashing on invalid JSON
This commit is contained in:
parent
418437aa6c
commit
9d242ab836
@ -49,13 +49,23 @@ class ResponseViewer extends Component {
|
||||
/>
|
||||
);
|
||||
case PREVIEW_MODE_SOURCE:
|
||||
let mode = contentType;
|
||||
|
||||
try {
|
||||
// FEATURE: Detect JSON even without content-type
|
||||
contentType.indexOf('json') === -1 && JSON.parse(body);
|
||||
mode = 'application/json';
|
||||
} catch (e) {
|
||||
// Nothing
|
||||
}
|
||||
|
||||
return (
|
||||
<Editor
|
||||
value={body || ''}
|
||||
updateFilter={updateFilter}
|
||||
filter={filter}
|
||||
autoPrettify={true}
|
||||
mode={contentType}
|
||||
mode={mode}
|
||||
readOnly={true}
|
||||
lineWrapping={editorLineWrapping}
|
||||
fontSize={editorFontSize}
|
||||
|
Loading…
Reference in New Issue
Block a user