Skip to content

Commit

Permalink
[common]bugfix: improve domain verification tools. (#963)
Browse files Browse the repository at this point in the history
  • Loading branch information
SPPan authored May 17, 2023
1 parent aa383af commit 0650bea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class IpDomainUtil {
* 域名校验正则
*/
private static final Pattern DOMAIN_PATTERN =
Pattern.compile("^(?=^.{3,255}$)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+$");
Pattern.compile("^(?=^.{3,255}$)[_a-zA-Z0-9][-_a-zA-Z0-9]{0,62}(\\.[a-zA-Z0-9][-_a-zA-Z0-9]{0,62})+$");

private static final String LOCALHOST = "localhost";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ void validateIpDomain() {
assertTrue(IpDomainUtil.validateIpDomain("www.student.dev.com.cn"));
assertTrue(IpDomainUtil.validateIpDomain("www.baidu.com"));
assertTrue(IpDomainUtil.validateIpDomain("good.didi"));
assertTrue(IpDomainUtil.validateIpDomain("spider_rds.sogou"));
assertTrue(IpDomainUtil.validateIpDomain("_redis.hn.sogou"));
assertFalse(IpDomainUtil.validateIpDomain("tmp"));
assertFalse(IpDomainUtil.validateIpDomain("good"));
assertFalse(IpDomainUtil.validateIpDomain("www.baidu.com."));
Expand Down

0 comments on commit 0650bea

Please sign in to comment.