Skip to content

Commit

Permalink
Merge pull request #7 from aradalvand/main
Browse files Browse the repository at this point in the history
Check blocked words against alphabet case-insensitively
  • Loading branch information
4kimov authored Aug 30, 2023
2 parents 2127f4d + c9c8b28 commit 35511dc
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,14 @@ export default class Sqids {
// 2. no words less than 3 chars
// 3. if some words contain chars that are not in the alphabet, remove those
const filteredBlocklist = new Set<string>();
const alphabetChars = alphabet.split('');
const alphabetChars = alphabet.toLowerCase().split('');
for (const word of blocklist) {
if (word.length >= 3) {
const wordChars = word.split('');
const wordLowercased = word.toLowerCase();
const wordChars = wordLowercased.split('');
const intersection = wordChars.filter((c) => alphabetChars.includes(c));
if (intersection.length == wordChars.length) {
filteredBlocklist.add(word.toLowerCase());
filteredBlocklist.add(wordLowercased);
}
}
}
Expand Down

0 comments on commit 35511dc

Please sign in to comment.