We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent be32fe0 commit 7abc5f5Copy full SHA for 7abc5f5
cmd/root.go
@@ -7,25 +7,14 @@ import (
7
"net"
8
"os"
9
"strings"
10
+ "regexp"
11
)
12
13
func isValidDomain(url string) bool {
- url = strings.ToLower(url)
14
- //check if url is an ip address
15
- if ip := net.ParseIP(url); ip != nil {
16
- return true
17
- }
18
-
19
- for _, c := range url {
20
- if c == '.' {
21
- continue
22
23
24
- subs := strings.Split(url, ".")
25
- if len(subs) < 2 {
26
- return false
27
28
+ //check if url is an ip address
+ if ip := net.ParseIP(url); ip != nil { return true }
+ if regexp.MustCompile(`^(([a-z-])\.?)*$`).MatchString(strings.ToLower(url)) { return true }
+ return false
29
}
30
31
var rootCmd = &cobra.Command{
0 commit comments