Skip to content

Commit

Permalink
feat: add methods definition and test unsing string with numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
rodgeraraujo committed Oct 10, 2020
1 parent ee27a4d commit 7b4d18c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/data/dictionary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ export default {
'Fukkin',
'g00k',
'God-damned',
'Handjob',
'H4ndjob',
'h00r',
'h0ar',
'h0re',
Expand Down Expand Up @@ -595,6 +597,8 @@ export default {
'Iscrota',
'Iscroto',
'Japa',
'Lesbian',
'L3sbi4n',
'Ladra',
'Ladrao',
'Ladroeira',
Expand Down
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class Profanity {
}

/**
* Censure a word with placeHolder characters;
* Censure a word with placeHolder characters.
* @param {any} word - String to censure.
* @public
*/
Expand Down Expand Up @@ -153,13 +153,23 @@ export class Profanity {
return '';
}

/**
* Add word(s) to wordlist filter.
* @param {...string} words - Word(s) to add to wordlist.
* @public
*/
addWords(...words: string[]) {
if (words.length === 0)
console.error('Unexpected error: need at last one word');
this.wordlist?.push(...words);
return this;
}

/**
* Remove word(s) to wordlist filter.
* @param {...string} words - Word(s) to be removed from wordlist.
* @public
*/
removeWords(...words: string[]) {
if (words.length === 0)
console.error('Unexpected error: need at last one word to remove');
Expand Down
4 changes: 2 additions & 2 deletions test/unit/isProfane.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ describe('isProfane tests', () => {
assert(profanity.isProfane('You\'re an asshole^ you are'));
});

it('should return true if detect profrane words with type case', () => {
it('should return true if detect profrane words and numberswith', () => {
const profanity = new Profanity('', {
language: 'en-us',
});

assert(profanity.isProfane('FuCk'));
assert(profanity.isProfane('That l3sbi4n did a very good H4ndjob.'));
});
});

0 comments on commit 7b4d18c

Please sign in to comment.