From 2fd52afa65c00fb48e52a039fb4cd2f41c6967a8 Mon Sep 17 00:00:00 2001
From: mohammad <mohammad.alayoub@mni.thm.de>
Date: Tue, 18 May 2021 20:08:03 +0200
Subject: [PATCH] merged all language-arrays together

---
 .../util/topic-cloud-admin.service.ts         | 25 +++----------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/src/app/services/util/topic-cloud-admin.service.ts b/src/app/services/util/topic-cloud-admin.service.ts
index c2a861cc5..9cb994c9f 100644
--- a/src/app/services/util/topic-cloud-admin.service.ts
+++ b/src/app/services/util/topic-cloud-admin.service.ts
@@ -20,27 +20,10 @@ export class TopicCloudAdminService {
 
   filterProfanityWords(str: string): string {
     let questionWithProfanity = str;
-
-    // German Profanity
-    this.badWords['de'].map(word =>{
-      questionWithProfanity = questionWithProfanity.toLowerCase().includes(word.toLowerCase()) ?
-      this.replaceString(questionWithProfanity.toLowerCase(), word.toLowerCase(), this.generateXWord(word.length))
-      : questionWithProfanity;
-    });
-    // English Profanity
-    this.badWords['en'].map(word =>{
-      questionWithProfanity = questionWithProfanity.toLowerCase().includes(word.toLowerCase()) ?
-      this.replaceString(questionWithProfanity.toLowerCase(), word.toLowerCase(), this.generateXWord(word.length))
-      : questionWithProfanity;
-    });
-    // French Profanity
-    this.badWords['fr'].map(word =>{
-      questionWithProfanity = questionWithProfanity.toLowerCase().includes(word.toLowerCase()) ?
-      this.replaceString(questionWithProfanity.toLowerCase(), word.toLowerCase(), this.generateXWord(word.length))
-      : questionWithProfanity;
-    });
-    // Custom Profanity
-    this.badWords['custom'].map(word =>{
+    /* put all arrays of languages together */
+    const profanityWords = this.badWords['en'].concat(this.badWords['de'])
+                           .concat(this.badWords['fr']).concat(this.badWords['custom']);
+    profanityWords.map(word =>{
       questionWithProfanity = questionWithProfanity.toLowerCase().includes(word.toLowerCase()) ?
       this.replaceString(questionWithProfanity.toLowerCase(), word.toLowerCase(), this.generateXWord(word.length))
       : questionWithProfanity;
-- 
GitLab