fix(chat) avoid emojifying URLs
Fixes: https://github.com/jitsi/jitsi-meet/issues/9661
This commit is contained in:
parent
e67db2381e
commit
b15f1d190d
|
@ -26,11 +26,27 @@ class ChatMessage extends AbstractChatMessage<Props> {
|
||||||
const { message, t } = this.props;
|
const { message, t } = this.props;
|
||||||
const processedMessage = [];
|
const processedMessage = [];
|
||||||
|
|
||||||
// content is an array of text and emoji components
|
const txt = this._getMessageText();
|
||||||
const content = toArray(this._getMessageText(), { className: 'smiley' });
|
|
||||||
|
// 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 => {
|
content.forEach(i => {
|
||||||
if (typeof i === 'string') {
|
if (typeof i === 'string' && i !== ' ') {
|
||||||
processedMessage.push(<Linkify key = { i }>{ i }</Linkify>);
|
processedMessage.push(<Linkify key = { i }>{ i }</Linkify>);
|
||||||
} else {
|
} else {
|
||||||
processedMessage.push(i);
|
processedMessage.push(i);
|
||||||
|
|
Loading…
Reference in New Issue