Profile: Fix parsing multiple links in bio (#1219)
This commit is contained in:
parent
15300721c3
commit
82a9fdefe7
@ -1,7 +1,7 @@
|
|||||||
import React from '../../../lib/teact/teact';
|
import React from '../../../lib/teact/teact';
|
||||||
import EMOJI_REGEX, { removeVS16s } from '../../../lib/twemojiRegex';
|
import EMOJI_REGEX, { removeVS16s } from '../../../lib/twemojiRegex';
|
||||||
|
|
||||||
import { RE_LINK_TEMPLATE } from '../../../config';
|
import { RE_LINK_TEMPLATE, RE_MENTION_TEMPLATE } from '../../../config';
|
||||||
import { IS_EMOJI_SUPPORTED } from '../../../util/environment';
|
import { IS_EMOJI_SUPPORTED } from '../../../util/environment';
|
||||||
import { nativeToUnfified } from '../../../util/emoji';
|
import { nativeToUnfified } from '../../../util/emoji';
|
||||||
import buildClassName from '../../../util/buildClassName';
|
import buildClassName from '../../../util/buildClassName';
|
||||||
@ -177,8 +177,7 @@ function addHighlight(textParts: TextPart[], highlight: string | undefined): Tex
|
|||||||
}, [] as TextPart[]);
|
}, [] as TextPart[]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const RE_LINK = new RegExp(RE_LINK_TEMPLATE, 'ig');
|
const RE_LINK = new RegExp(`${RE_LINK_TEMPLATE}|${RE_MENTION_TEMPLATE}`, 'ig');
|
||||||
const RE_MENTION = /@[\w\d_-]+/ig;
|
|
||||||
|
|
||||||
function addLinks(textParts: TextPart[]): TextPart[] {
|
function addLinks(textParts: TextPart[]): TextPart[] {
|
||||||
return textParts.reduce((result, part) => {
|
return textParts.reduce((result, part) => {
|
||||||
@ -186,8 +185,8 @@ function addLinks(textParts: TextPart[]): TextPart[] {
|
|||||||
return [...result, part];
|
return [...result, part];
|
||||||
}
|
}
|
||||||
|
|
||||||
const links = [...(part.match(RE_LINK) || []), ...(part.match(RE_MENTION) || [])];
|
const links = part.match(RE_LINK);
|
||||||
if (!links.length) {
|
if (!links || !links.length) {
|
||||||
return [...result, part];
|
return [...result, part];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -115,6 +115,7 @@ export const CONTENT_TYPES_FOR_QUICK_UPLOAD = 'image/png,image/gif,image/jpeg,vi
|
|||||||
|
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
export const RE_LINK_TEMPLATE = '((ftp|https?):\\/\\/)?((www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6})\\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)';
|
export const RE_LINK_TEMPLATE = '((ftp|https?):\\/\\/)?((www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z0-9()]{1,6})\\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)';
|
||||||
|
export const RE_MENTION_TEMPLATE = '(@[\\w\\d_-]+)';
|
||||||
export const RE_TME_LINK = /^(?:https?:\/\/)?(?:t\.me\/)([\d\w_]+)(?:\/([\d]+))?$/gm;
|
export const RE_TME_LINK = /^(?:https?:\/\/)?(?:t\.me\/)([\d\w_]+)(?:\/([\d]+))?$/gm;
|
||||||
export const RE_TME_INVITE_LINK = /^(?:https?:\/\/)?(?:t\.me\/joinchat\/)([\d\w_-]+)?$/gm;
|
export const RE_TME_INVITE_LINK = /^(?:https?:\/\/)?(?:t\.me\/joinchat\/)([\d\w_-]+)?$/gm;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user