@2toad/profanity
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -14,2 +14,3 @@ "use strict"; | ||
exists(text) { | ||
this.regex.lastIndex = 0; | ||
return this.regex.test(text); | ||
@@ -30,3 +31,3 @@ } | ||
const pattern = `${this.options.wholeWord ? '\\b' : ''}(${this.words.join('|')})${this.options.wholeWord ? '\\b' : ''}`; | ||
this.regex = new RegExp(pattern, 'i'); | ||
this.regex = new RegExp(pattern, 'ig'); | ||
} | ||
@@ -33,0 +34,0 @@ } |
@@ -8,3 +8,3 @@ "use strict"; | ||
it('should return true when profanity exists in a sentence', () => { | ||
chai_1.expect(_1.profanity.exists('Should we censor the word butt?')).to.equal(true); | ||
chai_1.expect(_1.profanity.exists('I like big butts and I cannot lie')).to.equal(true); | ||
}); | ||
@@ -14,6 +14,6 @@ it('should return true when profanity exists as a single word', () => { | ||
}); | ||
it('should return false when concatenated profanity exists in a sentence', () => { | ||
it('should return false when profanity is not a whole word in a sentence', () => { | ||
chai_1.expect(_1.profanity.exists('Should we censor the word buttArse?')).to.equal(false); | ||
}); | ||
it('should return true when profanity exists on multiple lines', () => { | ||
it('should return true when profanity exists within multiple lines', () => { | ||
chai_1.expect(_1.profanity.exists(` | ||
@@ -26,3 +26,3 @@ Nothing profane on line 1. | ||
it('should return false when profanity does not exist', () => { | ||
chai_1.expect(_1.profanity.exists('Should we censor the word 2Toad?')).to.equal(false); | ||
chai_1.expect(_1.profanity.exists('I like big glutes and I cannot lie')).to.equal(false); | ||
}); | ||
@@ -34,6 +34,6 @@ }); | ||
const customProfanity = new _1.Profanity(options); | ||
it('should return true when concatenated profanity exists in a sentence', () => { | ||
it('should return true when profanity is not a whole word in a sentence', () => { | ||
chai_1.expect(customProfanity.exists('Should we censor the word buttArse?')).to.equal(true); | ||
}); | ||
it('should return true when concatenated profanity exists on multiple lines', () => { | ||
it('should return true when profanity is not a whole word, within multiple lines', () => { | ||
chai_1.expect(customProfanity.exists(` | ||
@@ -46,3 +46,3 @@ Nothing profane on line 1. | ||
it('should return false when profanity does not exist', () => { | ||
chai_1.expect(customProfanity.exists('Should we censor the word 2Toad?')).to.equal(false); | ||
chai_1.expect(customProfanity.exists('I like big glutes and I cannot lie')).to.equal(false); | ||
}); | ||
@@ -55,7 +55,7 @@ it('should return true when concatenated profanity exists as a single word', () => { | ||
it('should replace profanity with grawlix in a sentence', () => { | ||
const censored = _1.profanity.censor('Should we censor the word butt?'); | ||
const censored = _1.profanity.censor('I like big butts and I cannot lie'); | ||
chai_1.expect(censored.includes(_1.profanity.options.grawlix)).to.equal(true); | ||
}); | ||
it('should remove profanity from a sentence', () => { | ||
const censored = _1.profanity.censor('Should we censor the word butt?'); | ||
const censored = _1.profanity.censor('I like big butts (aka arses) and I cannot lie'); | ||
chai_1.expect(_1.profanity.exists(censored)).to.equal(false); | ||
@@ -72,3 +72,3 @@ }); | ||
it('should not alter sentence without profanity', () => { | ||
const original = 'Should we censor the word 2Toad?'; | ||
const original = 'I like big glutes and I cannot lie'; | ||
const censored = _1.profanity.censor(original); | ||
@@ -85,8 +85,8 @@ chai_1.expect(censored).to.equal(original); | ||
it('should remove a single word from the list of profane words', () => { | ||
customProfanity.removeWords(['butt']); | ||
chai_1.expect(customProfanity.exists('Should we censor the word butt?')).to.equal(false); | ||
customProfanity.removeWords(['butts']); | ||
chai_1.expect(customProfanity.exists('I like big butts and I cannot lie')).to.equal(false); | ||
}); | ||
it('should remove mulitple words from the list of profane words', () => { | ||
customProfanity.removeWords(['butt', 'arse']); | ||
chai_1.expect(customProfanity.exists('Should we censor the word butt or arse?')).to.equal(false); | ||
customProfanity.removeWords(['butts', 'arses']); | ||
chai_1.expect(customProfanity.exists('I like big butts (aka arses) and I cannot lie')).to.equal(false); | ||
}); | ||
@@ -102,3 +102,3 @@ }); | ||
customProfanity.addWords(['aardvark', 'zebra']); | ||
chai_1.expect(customProfanity.exists('Should we censor the word aardvark or zebra?')).to.equal(true); | ||
chai_1.expect(customProfanity.exists('Should we censor the word aardvark and zebra?')).to.equal(true); | ||
}); | ||
@@ -105,0 +105,0 @@ }); |
@@ -10,2 +10,3 @@ 4r5e | ||
arse | ||
arses | ||
ass | ||
@@ -12,0 +13,0 @@ ass-fucker |
{ | ||
"name": "@2toad/profanity", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "A JavaScript profanity filter", | ||
@@ -5,0 +5,0 @@ "homepage": "https://github.com/2Toad/Profanity", |
# Profanity | ||
[![GitHub version](https://badge.fury.io/gh/2Toad%2Fprofanity.svg)](https://badge.fury.io/gh/2Toad%2Fprofanity) | ||
[![GitHub version](https://badge.fury.io/gh/2Toad%2FProfanity.svg)](https://badge.fury.io/gh/2Toad%2FProfanity) | ||
[![Downloads](https://img.shields.io/npm/dm/@2toad/profanity.svg)](https://www.npmjs.com/package/@2toad/profanity) | ||
[![Build Status](https://travis-ci.org/2Toad/profanity.svg?branch=master)](https://travis-ci.org/2Toad/profanity) | ||
[![Build Status](https://travis-ci.org/2Toad/Profanity.svg?branch=master)](https://travis-ci.org/2Toad/Profanity) | ||
@@ -25,6 +25,6 @@ A JavaScript profanity filter | ||
profanity.exists('I like big buttocks and I cannot lie'); | ||
profanity.exists('I like big glutes and I cannot lie'); | ||
// false | ||
profanity.censor('I like big butts (and ar5e) and I cannot lie'); | ||
profanity.censor('I like big butts (aka arses) and I cannot lie'); | ||
// I like big @#$%&! (and @#$%&!) and I cannot lie | ||
@@ -31,0 +31,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24499
314