From 923761c2674e392c443cff995b066116672cdad9 Mon Sep 17 00:00:00 2001 From: Tyler Akins Date: Fri, 20 Nov 2020 12:51:34 -0600 Subject: [PATCH] Expose `buildRegex()` This allows me to parse my own AST from Lucene, then modify the tree before passing it to buildRegex(). This is needed so I can have more control over the operator, such as handling different default operators. --- lib/lucene_to_regex.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/lucene_to_regex.js b/lib/lucene_to_regex.js index 6cbe2aa..3784248 100644 --- a/lib/lucene_to_regex.js +++ b/lib/lucene_to_regex.js @@ -36,10 +36,11 @@ const buildRegex = (ast, negate) => { module.exports = { parse: lucene.parse, toString: lucene.toString, + buildRegex: buildRegex, toRegex: (query, flag) => { const ast = lucene.parse(query) const regex = `^${buildRegex(ast)}.*$` return new RegExp(regex, flag) } -} \ No newline at end of file +}