From c4d061b75dc683a1565711102746fe66728bb590 Mon Sep 17 00:00:00 2001 From: Luka Skukan Date: Mon, 20 Feb 2017 12:38:31 +0100 Subject: [PATCH] Fix inGroups prop resolution --- src/utils.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/utils.js b/src/utils.js index db85aab..d29a880 100644 --- a/src/utils.js +++ b/src/utils.js @@ -457,8 +457,19 @@ class Utils { return false; } - var scope = JSON.parse(JSON.stringify(groups)); - var expressionFn = this.makePredicateFunction(expression); + if (!Array.isArray(groups) && typeof groups.items !== 'undefined') { + groups = groups.items.map((group) => group.name); + } + + const scope = JSON.parse(JSON.stringify(groups)); + let expressionFn; + + try { + expressionFn = this.makePredicateFunction(expression); + } catch(err) { + this.logWarning('GroupExpression', `Invalid boolean group expression: "${expression}"`); + return false; + } expression.match(/(\w+)/gmi).forEach((wordMatch) => { if (!(wordMatch in scope)) {