Browse Source

fix(chat) avoid emojifying URLs

Fixes: https://github.com/jitsi/jitsi-meet/issues/9661
master
Saúl Ibarra Corretgé 4 years ago
parent
commit
b15f1d190d
1 changed files with 19 additions and 3 deletions
  1. 19
    3
      react/features/chat/components/web/ChatMessage.js

+ 19
- 3
react/features/chat/components/web/ChatMessage.js View File

26
         const { message, t } = this.props;
26
         const { message, t } = this.props;
27
         const processedMessage = [];
27
         const processedMessage = [];
28
 
28
 
29
-        // content is an array of text and emoji components
30
-        const content = toArray(this._getMessageText(), { className: 'smiley' });
29
+        const txt = this._getMessageText();
30
+
31
+        // Tokenize the text in order to avoid emoji substitution for URLs.
32
+        const tokens = txt.split(' ');
33
+
34
+        // Content is an array of text and emoji components
35
+        const content = [];
36
+
37
+        for (const token of tokens) {
38
+            if (token.includes('://')) {
39
+                // It contains a link, bypass the emojification.
40
+                content.push(token);
41
+            } else {
42
+                content.push(...toArray(token, { className: 'smiley' }));
43
+            }
44
+
45
+            content.push(' ');
46
+        }
31
 
47
 
32
         content.forEach(i => {
48
         content.forEach(i => {
33
-            if (typeof i === 'string') {
49
+            if (typeof i === 'string' && i !== ' ') {
34
                 processedMessage.push(<Linkify key = { i }>{ i }</Linkify>);
50
                 processedMessage.push(<Linkify key = { i }>{ i }</Linkify>);
35
             } else {
51
             } else {
36
                 processedMessage.push(i);
52
                 processedMessage.push(i);

Loading…
Cancel
Save