fix(chat) avoid emojifying URLs

Fixes: https://github.com/jitsi/jitsi-meet/issues/9661
This commit is contained in:
Saúl Ibarra Corretgé 2021-08-25 15:00:26 +02:00 committed by Дамян Минков
parent e67db2381e
commit b15f1d190d
1 changed files with 19 additions and 3 deletions

View File

@ -26,11 +26,27 @@ class ChatMessage extends AbstractChatMessage<Props> {
const { message, t } = this.props;
const processedMessage = [];
// content is an array of text and emoji components
const content = toArray(this._getMessageText(), { className: 'smiley' });
const txt = this._getMessageText();
// Tokenize the text in order to avoid emoji substitution for URLs.
const tokens = txt.split(' ');
// Content is an array of text and emoji components
const content = [];
for (const token of tokens) {
if (token.includes('://')) {
// It contains a link, bypass the emojification.
content.push(token);
} else {
content.push(...toArray(token, { className: 'smiley' }));
}
content.push(' ');
}
content.forEach(i => {
if (typeof i === 'string') {
if (typeof i === 'string' && i !== ' ') {
processedMessage.push(<Linkify key = { i }>{ i }</Linkify>);
} else {
processedMessage.push(i);