-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_badwords.ts
More file actions
49 lines (40 loc) · 1.58 KB
/
Copy pathdebug_badwords.ts
File metadata and controls
49 lines (40 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import * as fs from 'fs';
import * as path from 'path';
const csvPath = path.join(__dirname, 'src/utils/badWords.csv');
const badWordsRaw = fs.readFileSync(csvPath, 'utf-8');
// Parse exactly like badWords.ts does
const badWords = badWordsRaw.split('\n').map(word => word.replace(/,/g, '').trim().toLowerCase()).filter(Boolean);
console.log(`Total bad words loaded: ${badWords.length}`);
console.log('First 10 words:', badWords.slice(0, 10));
console.log('Last 10 words:', badWords.slice(-10));
// Test specific words that should be blocked
const testWords = ['badword', 'a55', 'stupid', 'idiot', 'kill', 'hate'];
testWords.forEach(word => {
const isBlocked = badWords.includes(word);
console.log(`"${word}" in list: ${isBlocked}`);
});
// Test the containsBadWords function
const containsBadWords = (text: string): boolean => {
const lowerText = text.toLowerCase();
return badWords.some((word) => lowerText.includes(word));
};
const testPhrases = [
'Hello world',
'You are stupid',
'This is a55',
'I hate you',
'Nice day',
'Idiot person'
];
console.log('\n--- Testing phrases ---');
testPhrases.forEach(phrase => {
const blocked = containsBadWords(phrase);
console.log(`"${phrase}": ${blocked ? 'BLOCKED' : 'ALLOWED'}`);
});
// Check for carriage return issues
console.log('\n--- Checking for \\r characters ---');
const wordsWithCR = badWords.filter(word => word.includes('\r'));
console.log(`Words with \\r: ${wordsWithCR.length}`);
if (wordsWithCR.length > 0) {
console.log('Sample words with CR:', wordsWithCR.slice(0, 5).map(w => JSON.stringify(w)));
}