UNPKG

@aikidosec/firewall

Version:

Zen by Aikido is an embedded Web Application Firewall that autonomously protects Node.js apps against common and critical attacks

20 lines (19 loc) 667 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.convertRequestBodyToString = convertRequestBodyToString; const isPlainObject_1 = require("./isPlainObject"); function convertRequestBodyToString(body, maxLength = 16384) { if (typeof body === "string") { return body.length > maxLength ? body.slice(0, maxLength) : body; } if ((0, isPlainObject_1.isPlainObject)(body)) { try { const serialized = JSON.stringify(body, null, 2); return convertRequestBodyToString(serialized, maxLength); } catch { return undefined; } } return undefined; }