From 2a877e05f09163933f41ab94d85fb8cbff29279a Mon Sep 17 00:00:00 2001 From: Josh Guyette Date: Fri, 5 Jan 2024 14:50:18 -0600 Subject: [PATCH] removed set, replaces need to happen from longest word to shortest word --- src/FamilyFriendly.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/FamilyFriendly.ts b/src/FamilyFriendly.ts index 74adb13..8114c94 100644 --- a/src/FamilyFriendly.ts +++ b/src/FamilyFriendly.ts @@ -23,7 +23,7 @@ export interface FamilyFriendlyOptions { // This class is used to detect or mask out, bad words in a string export class FamilyFriendly { // The list of bad words - private badWords = new Set(); + private badWords: string[] = []; constructor(options?: FamilyFriendlyOptions) { const allFalse = @@ -92,7 +92,7 @@ export class FamilyFriendly { allWords.push(...badSpanishWords); } - this.badWords = new Set(allWords); + this.badWords = allWords.sort((a, b) => b.length - a.length); } // Returns true if the string contains a bad word