@aikidosec/firewall
Version:
Zen by Aikido is an embedded Web Application Firewall that autonomously protects Node.js apps against common and critical attacks
14 lines (13 loc) • 574 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.escapeStringRegexp = escapeStringRegexp;
/**
* Escape characters with special meaning either inside or outside character sets.
*
* Use a simple backslash escape when it’s always valid, and a `\xnn` escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
*
* Taken from https://github.com/sindresorhus/escape-string-regexp/
*/
function escapeStringRegexp(string) {
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
}