From e9631211a209da2db21f94d9e1ee69e2fa01934c Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Sat, 23 Oct 2021 14:43:54 +0100 Subject: [PATCH] [FIX] ensure punctuation is ignored correctly --- functions/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/functions/index.js b/functions/index.js index 73c4732..f4577c0 100644 --- a/functions/index.js +++ b/functions/index.js @@ -458,7 +458,7 @@ function arraysHaveSameMembers(arr1, arr2) { * @return {string} The original string with the unwanted characters removed. */ function cleanseVocabString(item) { - const chars = /[ °"§%()\[\]{}=\\?´`'#<>|,;.:+_-]+/g; + const chars = /[ °"§%()\[\]{}=\\?´`'#<>|,;.:+_-!£$^&*~/]+/g; return item.replace(chars, ""); } @@ -527,7 +527,7 @@ exports.processAnswer = functions.https.onCall((data, context) => { const mode = docData.mode; const correctAnswers = answerDoc.data().item; const splitCorrectAnswers = correctAnswers.split("/"); - const cleansedSplitCorrectAnswers = cleanseVocabString(correctAnswers).split("/"); + const cleansedSplitCorrectAnswers = splitCorrectAnswers.map((answer) => cleanseVocabString(answer)); const cleansedInputAnswer = cleanseVocabString(inputAnswer); let isCorrectAnswer = false;