Reinforced domain regex match

This commit is contained in:
kenshinx 2015-07-07 17:32:45 +08:00
parent 5c651bacf3
commit 61f68d2b27
1 changed files with 1 additions and 1 deletions

View File

@ -145,7 +145,7 @@ func (f *FileHosts) isDomain(domain string) bool {
if f.isIP(domain) {
return false
}
match, _ := regexp.MatchString("^[a-zA-Z0-9][a-zA-Z0-9-]", domain)
match, _ := regexp.MatchString(`^([a-zA-Z0-9]([a-zA-Z0-9\-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,6}$`, domain)
return match
}