[console] Set multiline json content type to application/x-ndjson

This commit is contained in:
Jonathan Budzenski 2017-02-06 12:22:03 -06:00
parent 912454a31f
commit 8a703d868e
No known key found for this signature in database
GPG key ID: D28BF9418FA0F292

View file

@ -23,8 +23,17 @@ module.exports.send = function (method, path, data, server, disable_auth_alert)
try {
JSON.parse(data);
contentType = 'application/json';
} catch (e) {
contentType = 'text/plain';
}
catch (e) {
try {
data.split('\n').forEach(line => {
if (!line) return;
JSON.parse(line);
});
contentType = 'application/x-ndjson';
} catch (e){
contentType = 'text/plain';
}
}
}