-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathregex_and_control.go
68 lines (61 loc) · 1.17 KB
/
regex_and_control.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package main
import (
"fmt"
"regexp"
)
func isMayIPv4(host string) bool {
match, err := regexp.MatchString(ipv4Regex+`|`+domainRegex, host)
if err != nil {
fmt.Println(err)
return false
}
return match
}
func isMayOnlyIPv4(host string) bool {
match, err := regexp.MatchString(ipv4Regex, host)
if err != nil {
fmt.Println(err)
return false
}
return match
}
func isMayIPv6(host string) bool {
match, err := regexp.MatchString(ipv6Regex+`|`+domainRegex, host)
if err != nil {
fmt.Println(err)
return false
}
return match
}
func isMayOnlyIPv6(host string) bool {
match, err := regexp.MatchString(ipv6Regex, host)
if err != nil {
fmt.Println(err)
return false
}
return match
}
func isHTTPURLScheme(scheme string) bool {
match, err := regexp.MatchString(`^http$|^https$`, scheme)
if err != nil {
fmt.Println(err)
return false
}
return match
}
func isPortValid(port string) bool {
match, err := regexp.MatchString(portRegex, port)
if err != nil {
fmt.Println(err)
return false
}
return match
}
func isMayDomain(host string) bool {
match, err := regexp.MatchString(domainRegex, host)
if err != nil {
fmt.Println(err)
return false
}
return match
}