From b8c44c9fe286cdb911806687387cf4c21dd4f55b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=86=8A?= Date: Sun, 20 Jul 2025 10:27:57 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=AD=A3=E5=88=99=E8=A1=A8=E8=BE=BE?= =?UTF-8?q?=E5=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/common/constant/RegexConstants.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/continew-common/src/main/java/top/continew/admin/common/constant/RegexConstants.java b/continew-common/src/main/java/top/continew/admin/common/constant/RegexConstants.java index 2762151f..70a8e71a 100644 --- a/continew-common/src/main/java/top/continew/admin/common/constant/RegexConstants.java +++ b/continew-common/src/main/java/top/continew/admin/common/constant/RegexConstants.java @@ -70,11 +70,20 @@ public class RegexConstants { * 域名、IPV4、IPV6 *

*/ - public static final String HTTP_HOST = """ - ^((?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,}| - (?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)| - (?:(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}| - """; + public static final String HTTP_HOST = + "^(" + + // ① 域名 + "(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?\\.)+[A-Za-z]{2,63}" + + "|" + + // ② IPv4 + "(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)" + + "|" + + // ③ IPv6(8 组 1-4 位十六进制,用 : 分隔,支持压缩 0) + "(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}" + + "|" + + // ④ IPv6 压缩形式(::) + "(?:[0-9A-Fa-f]{1,4}:){0,6}::(?:[0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4}" + + ")$"; private RegexConstants() { }