fix: 链接消息处理问题

This commit is contained in:
kuaifan 2022-11-23 22:51:26 +08:00
parent e6aef83bbe
commit 69ced1a02f
2 changed files with 2 additions and 2 deletions

View File

@ -671,7 +671,7 @@ class WebSocketDialogMsg extends AbstractModel
$text = str_replace($matchs[0][$key], "[:{$matchChar[1]}:{$keyId}:{$matchValye[1]}:]", $text); $text = str_replace($matchs[0][$key], "[:{$matchChar[1]}:{$keyId}:{$matchValye[1]}:]", $text);
} }
// 文件分享链接 // 文件分享链接
preg_match_all("/(https*:\/\/)((\w|=|\?|\.|\/|&|-|:|\+|%|;|#)+)/i", $text, $matchs); preg_match_all("/(?<=[^'\"])(https*:\/\/)((\w|=|\?|\.|\/|&|-|:|\+|%|;|#)+)/i", $text, $matchs);
if ($matchs) { if ($matchs) {
foreach ($matchs[0] as $str) { foreach ($matchs[0] as $str) {
preg_match("/\/single\/file\/(.*?)$/i", $str, $match); preg_match("/\/single\/file\/(.*?)$/i", $str, $match);

View File

@ -422,7 +422,7 @@
if (/https*:\/\//.test(text)) { if (/https*:\/\//.test(text)) {
text = text.split(/(<[^>]*>)/g).map(string => { text = text.split(/(<[^>]*>)/g).map(string => {
if (string && !/<[^>]*>/.test(string)) { if (string && !/<[^>]*>/.test(string)) {
string = string.replace(/(https*:\/\/)((\w|=|\?|\.|\/|&|-|:|\+|%|;|#)+)/g, "<a href=\"$1$2\" target=\"_blank\">$1$2</a>") string = string.replace(/(?<=[^'"])(https*:\/\/)((\w|=|\?|\.|\/|&|-|:|\+|%|;|#)+)/g, "<a href=\"$1$2\" target=\"_blank\">$1$2</a>")
} }
return string; return string;
}).join("") }).join("")