fix(string utils): do not escape possible regular expressions

This commit is contained in:
Matteo Pagliazzi
2020-04-28 16:47:52 +02:00
parent 2888f843e3
commit 61ca931e66
4 changed files with 16 additions and 19 deletions

View File

@@ -1,12 +1,8 @@
import escapeRegExp from 'lodash/escapeRegExp';
import bannedSlurs from '../bannedSlurs';
import { getMatchesByWordArray } from '../stringUtils';
import forbiddenUsernames from '../forbiddenUsernames';
const bannedSlurRegexs = bannedSlurs.map(word => {
const escapedWord = escapeRegExp(word);
return new RegExp(`.*${escapedWord}.*`, 'i');
});
const bannedSlurRegexs = bannedSlurs.map(word => new RegExp(`.*${word}.*`, 'i'));
export function nameContainsSlur (username) {
for (let i = 0; i < bannedSlurRegexs.length; i += 1) {