UNPKG

@aikidosec/firewall

Version:

Zen by Aikido is an embedded Application Firewall that autonomously protects Node.js apps against common and critical attacks, provides rate limiting, detects malicious traffic (including bots), and more.

18 lines (17 loc) 503 B
"use strict"; 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, "'"); }