From f6738e978d2acaeea60234f11bd464d2f518512e Mon Sep 17 00:00:00 2001 From: Yarmo Mackenbach Date: Mon, 26 Oct 2020 22:50:41 +0100 Subject: [PATCH] Fix regex --- src/claimVerification.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/claimVerification.js b/src/claimVerification.js index 7b5980a..bac5516 100644 --- a/src/claimVerification.js +++ b/src/claimVerification.js @@ -11,7 +11,7 @@ const runOnJson = (proofData, checkPath, checkClaim, checkRelation) => { switch (checkRelation) { default: case 'contains': - re = new RegExp(checkClaim, "gi") + re = new RegExp(checkClaim.replace('[', '\\[').replace(']', '\\]'), "gi") return re.test(proofData.replace(/\r?\n|\r/, '')) break case 'equals': @@ -27,7 +27,7 @@ const runOnJson = (proofData, checkPath, checkClaim, checkRelation) => { if (Array.isArray(proofData)) { proofData.forEach((item, i) => { isVerified = isVerified || runOnJson(item, checkPath, checkClaim, checkRelation) - }); + }) } else if (Array.isArray(proofData[checkPath[0]])) { proofData[checkPath[0]].forEach((item, i) => { isVerified = isVerified || runOnJson(item, checkPath.slice(1), checkClaim, checkRelation)