Skip to content

Take control over your live stream video by running it yourself. Streaming + chat out of the box.

highlighting: make case-insensitive, support unicode (#3137)

John Regan161d557a713c
diff --git a/web/components/chat/ChatUserMessage/customMatcher.ts b/web/components/chat/ChatUserMessage/customMatcher.ts
index d6136da1ac..b08d011833 100644
--- a/web/components/chat/ChatUserMessage/customMatcher.ts
+++ b/web/components/chat/ChatUserMessage/customMatcher.ts
@@ -19,7 +19,18 @@ export class ChatMessageHighlightMatcher extends Matcher {
return null;
}
- const result = str.match(highlightString);
+ const escapedString = highlightString
+ .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
+ .replace(/\s/g, '\\s');
+
+ const normalizedString = escapedString.normalize('NFD').replace(/[\u0300-\u036f]/g, '');
+
+ let highlightRegex = escapedString;
+ if (escapedString !== normalizedString) {
+ highlightRegex = `(?:${escapedString})|(?:${normalizedString})`;
+ }
+
+ const result = str.match(new RegExp(highlightRegex, 'ui'));
if (!result) {
return null;