From 014bbbdd4fc95d2886bdd74dc7d1175b03a67bfb Mon Sep 17 00:00:00 2001 From: Matthew Grove Date: Wed, 8 Sep 2021 12:21:22 +0100 Subject: [PATCH] Fix regex usage error and increase efficiency --- functions/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/functions/index.js b/functions/index.js index f990da2..8173e4a 100644 --- a/functions/index.js +++ b/functions/index.js @@ -5,7 +5,7 @@ const admin = require("firebase-admin"); admin.initializeApp(); const db = admin.firestore(); -const LOCAL_TESTING = false; +const LOCAL_TESTING = true; /** * Randomises the items in an array. @@ -360,6 +360,11 @@ function cleanseVocabString(item) { return newString; } +exports.cleanseVocabString = functions.https.onCall((data, context) => { + const chars = /[ °"§%()\[\]{}=\\?´`'#<>|,;.:+_-]+/g; + return data.replace(chars, ""); +}) + /** * Processes a response to a question in a vocab set. * @param {object} data The data passed to the function.