From 786e85686dece81ab3084d35a172529a0de8648c Mon Sep 17 00:00:00 2001 From: Chi Vinh Le Date: Wed, 8 Nov 2017 18:57:06 +0100 Subject: [PATCH] Fix invalid regexp for ie --- .../src/components/CommentBodyHighlighter.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/components/CommentBodyHighlighter.js b/client/coral-admin/src/components/CommentBodyHighlighter.js index e27d3ce6d..177df5338 100644 --- a/client/coral-admin/src/components/CommentBodyHighlighter.js +++ b/client/coral-admin/src/components/CommentBodyHighlighter.js @@ -15,7 +15,15 @@ function generateRegExp(phrases) { .join('[\\s"?!.]+') ).join('|'); - return new RegExp(`(^|[^\\w])(${inner})(?=[^\\w]|$)`, 'iu'); + const pattern = `(^|[^\\w])(${inner})(?=[^\\w]|$)`; + try { + return new RegExp(pattern, 'iu'); + } + catch (_err) { + + // IE does not support unicode support, so we'll create one without. + return new RegExp(pattern, 'i'); + } } // Generate a regular expression detecting `suspectWords` and `bannedWords` phrases.