Skip to content

Commit 3908f3c

Browse files
leegouldweb-mech
authored andcommitted
fix(isProfane): Adding regex word boundary for isProfane
1 parent cee96d6 commit 3908f3c

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

lib/badwords.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var Filter = (function() {
2626
*/
2727
Filter.prototype.isProfane = function isProfane(string) {
2828
return string
29-
.split(' ')
29+
.split(/\b/)
3030
.map(function(w) {
3131
return w.toLowerCase().replace(this.regex, '');
3232
}, this)

test/isProfane.js

+4
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@ describe('filter', function(){
3131
});
3232
assert(filter.isProfane('test'));
3333
});
34+
35+
it('Should tokenize words according to regex word boundaries', function() {
36+
assert(filter.isProfane("that person is an\nasshole"));
37+
})
3438
});
3539
});

0 commit comments

Comments
 (0)