@aikidosec/firewall
Version:
Zen by Aikido is an embedded Web Application Firewall that autonomously protects Node.js apps against common and critical attacks
18 lines (17 loc) • 503 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.escapeLog = escapeLog;
/**
* Remove new line characters and escape backticks from a log message.
*
* Also truncates the log message to a maximum length.
*/
function escapeLog(log, maxLength = 256) {
if (!log || typeof log !== "string") {
return "";
}
if (log.length > maxLength) {
log = log.slice(0, maxLength) + "...";
}
return log.replace(/\n/g, " ").replace(/[`"]/g, "'");
}