From abdc9e532997ee0821a731466125c1624baba40e Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Tue, 11 Feb 2025 18:12:03 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=86=E5=88=ABurl=20=E6=AD=A3=E5=88=99?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/common/url.js | 4 ++-- im-web/src/api/url.js | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/im-uniapp/common/url.js b/im-uniapp/common/url.js index db2fb61..ff04275 100644 --- a/im-uniapp/common/url.js +++ b/im-uniapp/common/url.js @@ -1,6 +1,6 @@ let replaceURLWithHTMLLinks = (content, color) => { - // 使用正则表达式匹配更广泛的URL格式 - const urlRegex = /(?:https?:\/\/[^\s]+|www\.[^\s]+)/g; + // 使用正则表达式匹配更广泛的URL格式(此正则由deepseek生成) + const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]|\bwww\.[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; return content.replace(urlRegex, (url) => { // 如果URL不以http(s)://开头,则添加http://前缀 if (!url.startsWith("http")) { diff --git a/im-web/src/api/url.js b/im-web/src/api/url.js index db2fb61..ff04275 100644 --- a/im-web/src/api/url.js +++ b/im-web/src/api/url.js @@ -1,6 +1,6 @@ let replaceURLWithHTMLLinks = (content, color) => { - // 使用正则表达式匹配更广泛的URL格式 - const urlRegex = /(?:https?:\/\/[^\s]+|www\.[^\s]+)/g; + // 使用正则表达式匹配更广泛的URL格式(此正则由deepseek生成) + const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|]|\bwww\.[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; return content.replace(urlRegex, (url) => { // 如果URL不以http(s)://开头,则添加http://前缀 if (!url.startsWith("http")) {