Skip to content

Commit 35511dc

Browse files
authored
Merge pull request #7 from aradalvand/main
Check blocked words against alphabet case-insensitively
2 parents 2127f4d + c9c8b28 commit 35511dc

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/index.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,14 @@ export default class Sqids {
5151
// 2. no words less than 3 chars
5252
// 3. if some words contain chars that are not in the alphabet, remove those
5353
const filteredBlocklist = new Set<string>();
54-
const alphabetChars = alphabet.split('');
54+
const alphabetChars = alphabet.toLowerCase().split('');
5555
for (const word of blocklist) {
5656
if (word.length >= 3) {
57-
const wordChars = word.split('');
57+
const wordLowercased = word.toLowerCase();
58+
const wordChars = wordLowercased.split('');
5859
const intersection = wordChars.filter((c) => alphabetChars.includes(c));
5960
if (intersection.length == wordChars.length) {
60-
filteredBlocklist.add(word.toLowerCase());
61+
filteredBlocklist.add(wordLowercased);
6162
}
6263
}
6364
}

0 commit comments

Comments
 (0)