From 2596ce4de405b46439648c6fd1c3693d00ac755d Mon Sep 17 00:00:00 2001
From: mohammad <mohammad.alayoub@mni.thm.de>
Date: Wed, 16 Jun 2021 14:27:49 +0200
Subject: [PATCH] trim words before adding them to lists

---
 src/app/services/util/topic-cloud-admin.service.ts | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/app/services/util/topic-cloud-admin.service.ts b/src/app/services/util/topic-cloud-admin.service.ts
index 85e45e36d..8b54e677e 100644
--- a/src/app/services/util/topic-cloud-admin.service.ts
+++ b/src/app/services/util/topic-cloud-admin.service.ts
@@ -83,10 +83,10 @@ export class TopicCloudAdminService {
   addToProfanityList(word: string) {
     if (word !== undefined) {
       const newList = this.getCustomProfanityList();
-      if (newList.includes(word)) {
+      if (newList.includes(word.toLowerCase().trim())) {
         return;
       }
-      newList.push(word);
+      newList.push(word.toLowerCase().trim());
       localStorage.setItem(this.profanityKey, newList.toString());
     }
   }
@@ -113,8 +113,8 @@ export class TopicCloudAdminService {
     if (word !== undefined) {
       this.getRoom().subscribe(room => {
         const newlist = room.blacklist ? JSON.parse(room.blacklist) : [];
-        if (!newlist.includes(word)){
-          newlist.push(word.toLowerCase());
+        if (!newlist.includes(word.toLowerCase().trim())){
+          newlist.push(word.toLowerCase().trim());
         }
         this.updateBlacklist(newlist, room, 'add-successful');
       });
@@ -176,7 +176,7 @@ export class TopicCloudAdminService {
     this.profanityWords.concat(this.getCustomProfanityList()).map((word) => {
       questionWithProfanity = questionWithProfanity
         .toLowerCase()
-        .includes(word.toLowerCase())
+        .includes(word)
         ? this.replaceString(
           questionWithProfanity,
           word,
-- 
GitLab