Fix JSON parse error with Megalodon

This commit is contained in:
Jesse Wierzbinski 2024-04-07 02:30:45 -10:00
parent 26596bb987
commit 1115b72ca6
No known key found for this signature in database

View file

@ -95,13 +95,17 @@ export class LogManager {
const content_type = req.headers.get("Content-Type"); const content_type = req.headers.get("Content-Type");
if (content_type?.includes("application/json")) { if (content_type?.includes("application/json")) {
const json = await req.json(); try {
const stringified = JSON.stringify(json, null, 4) const json = await req.json();
.split("\n") const stringified = JSON.stringify(json, null, 4)
.map((line) => ` ${line}`) .split("\n")
.join("\n"); .map((line) => ` ${line}`)
.join("\n");
string += `${stringified}\n`; string += `${stringified}\n`;
} catch {
string += " [Invalid JSON]\n";
}
} else if ( } else if (
content_type && content_type &&
(content_type.includes("application/x-www-form-urlencoded") || (content_type.includes("application/x-www-form-urlencoded") ||