From 8599a858e4daa988748080b4e458365bd332b9fc Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 8 Nov 2023 10:35:29 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=89=8D=E5=90=8E=E7=AB=AF=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E6=A0=A1=E9=AA=8C=E4=BF=9D=E6=8C=81=E4=B8=80=E8=87=B4?= =?UTF-8?q?=20(#2842)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/utils/common/common.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/utils/common/common.go b/backend/utils/common/common.go index d13b69cfc..09b682d1f 100644 --- a/backend/utils/common/common.go +++ b/backend/utils/common/common.go @@ -222,7 +222,10 @@ func ConvertToPinyin(text string) string { } func IsValidDomain(domain string) bool { - pattern := `^([\w\\u4e00-\\u9fa5\\-\\*]{1,100}\.){1,10}([\w\\u4e00-\\u9fa5\\-]{1,24}|[\w\\u4e00-\\u9fa5\\-]{1,24}\.[\w\\u4e00-\\u9fa5\\-]{1,24})$` - match, _ := regexp.MatchString(pattern, domain) + pattern := `^([\w\p{Han}\-\*]{1,100}\.){1,10}([\w\p{Han}\-]{1,24}|[\w\p{Han}\-]{1,24}\.[\w\p{Han}\-]{1,24})(:\d{1,5})?$` + match, err := regexp.MatchString(pattern, domain) + if err != nil { + return false + } return match }