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

@@ -14,8 +14,6 @@ import {
TAVERN_ID,
} from '../../../../../website/server/models/group';
import { CHAT_FLAG_FROM_SHADOW_MUTE, MAX_MESSAGE_LENGTH } from '../../../../../website/common/script/constants';
import { getMatchesByWordArray } from '../../../../../website/server/libs/stringUtils';
import bannedWords from '../../../../../website/server/libs/bannedWords';
import guildsAllowingBannedWords from '../../../../../website/server/libs/guildsAllowingBannedWords';
import * as email from '../../../../../website/server/libs/email';
@@ -292,12 +290,6 @@ describe('POST /chat', () => {
.that.includes(testBannedWords.join(', '));
});
it('check all banned words are matched', async () => {
const message = bannedWords.join(',').replace(/\\/g, '');
const matches = getMatchesByWordArray(message, bannedWords);
expect(matches.length).to.equal(bannedWords.length);
});
it('does not error when bad word is suffix of a word', async () => {
const wordAsSuffix = `prefix${testBannedWordMessage}`;
const message = await user.post('/groups/habitrpg/chat', { message: wordAsSuffix });