|
|
|
@ -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]} />;
|
|
|
|
|