Skip to content

Commit 9411200

Browse files
committed
fix: fix problem of linkmeta will fetch tailchat's url and not match bbcode url
1 parent 3368e3c commit 9411200

File tree

1 file changed

+11
-3
lines changed
  • server/plugins/com.msgbyte.linkmeta/web/plugins/com.msgbyte.linkmeta/src

1 file changed

+11
-3
lines changed

server/plugins/com.msgbyte.linkmeta/web/plugins/com.msgbyte.linkmeta/src/index.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { regMessageExtraParser, regInspectService } from '@capital/common';
1+
import {
2+
regMessageExtraParser,
3+
regInspectService,
4+
getMessageTextDecorators,
5+
} from '@capital/common';
26
import { Translate } from './translate';
37
import urlRegex from 'url-regex';
48
import React from 'react';
@@ -7,9 +11,13 @@ import { UrlMetaPreviewer } from './UrlMetaPreviewer';
711
regMessageExtraParser({
812
name: 'com.msgbyte.linkmeta/urlParser',
913
render({ content }) {
10-
const matched = String(content).match(urlRegex());
14+
const matched = String(
15+
getMessageTextDecorators().serialize(String(content))
16+
).match(urlRegex());
1117
if (matched) {
12-
const urlMatch = matched.filter((m) => !m.includes('['));
18+
const urlMatch = matched
19+
.filter((m) => !m.includes('['))
20+
.filter((m) => !m.startsWith(window.location.origin));
1321

1422
if (urlMatch.length > 0 && typeof urlMatch[0] === 'string') {
1523
return <UrlMetaPreviewer url={urlMatch[0]} />;

0 commit comments

Comments
 (0)