removed set, replaces need to happen from longest word to shortest word
This commit is contained in:
parent
603ca61135
commit
2a877e05f0
|
@ -23,7 +23,7 @@ export interface FamilyFriendlyOptions {
|
||||||
// This class is used to detect or mask out, bad words in a string
|
// This class is used to detect or mask out, bad words in a string
|
||||||
export class FamilyFriendly {
|
export class FamilyFriendly {
|
||||||
// The list of bad words
|
// The list of bad words
|
||||||
private badWords = new Set<string>();
|
private badWords: string[] = [];
|
||||||
|
|
||||||
constructor(options?: FamilyFriendlyOptions) {
|
constructor(options?: FamilyFriendlyOptions) {
|
||||||
const allFalse =
|
const allFalse =
|
||||||
|
@ -92,7 +92,7 @@ export class FamilyFriendly {
|
||||||
allWords.push(...badSpanishWords);
|
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
|
// Returns true if the string contains a bad word
|
||||||
|
|
Loading…
Reference in New Issue