From 61f68d2b27d6322f615d97cb0dfb21f78e699dd6 Mon Sep 17 00:00:00 2001 From: kenshinx Date: Tue, 7 Jul 2015 17:32:45 +0800 Subject: [PATCH] Reinforced domain regex match --- hosts.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hosts.go b/hosts.go index 8357754..87bef5e 100644 --- a/hosts.go +++ b/hosts.go @@ -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 }