fix: fix problem of linkmeta will fetch tailchat's url and not match bbcode url

pull/146/merge
moonrailgun 1 year ago
parent 3368e3cc2f
commit 9411200ae3

@ -1,4 +1,8 @@
import { regMessageExtraParser, regInspectService } from '@capital/common';
import {
regMessageExtraParser,
regInspectService,
getMessageTextDecorators,
} from '@capital/common';
import { Translate } from './translate';
import urlRegex from 'url-regex';
import React from 'react';
@ -7,9 +11,13 @@ import { UrlMetaPreviewer } from './UrlMetaPreviewer';
regMessageExtraParser({
name: 'com.msgbyte.linkmeta/urlParser',
render({ content }) {
const matched = String(content).match(urlRegex());
const matched = String(
getMessageTextDecorators().serialize(String(content))
).match(urlRegex());
if (matched) {
const urlMatch = matched.filter((m) => !m.includes('['));
const urlMatch = matched
.filter((m) => !m.includes('['))
.filter((m) => !m.startsWith(window.location.origin));
if (urlMatch.length > 0 && typeof urlMatch[0] === 'string') {
return <UrlMetaPreviewer url={urlMatch[0]} />;

Loading…
Cancel
Save