From e94e5bba61dc52346f0dcc1575ca773097ae46a9 Mon Sep 17 00:00:00 2001 From: svrjs Date: Sun, 30 Jul 2023 01:19:50 +0200 Subject: [PATCH] Added regex string (like in SVR.JS config) support --- index.js | 19 +++++++++++++++++++ mod.info | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 9c52a23..63ca585 100755 --- a/index.js +++ b/index.js @@ -8,6 +8,24 @@ var url = require("url"); var easywafconfig = {}; var logm = {}; if (fs.existsSync("easywaf-config.json")) easywafconfig = JSON.parse(fs.readFileSync("easywaf-config.json").toString()) +function createRegex(regex) { + var regexObj = regex.split("/"); + if (regexObj.length == 0) throw new Error("Invalid regex!"); + var modifiers = regexObj.pop(); + regexObj.shift(); + var searchString = regexObj.join("/"); + return new RegExp(searchString, modifiers); +} + +if(easywafconfig.modules) { + var moduleOptions = Object.keys(easywafconfig.modules); + for(var i=0;i