toWhitelist gets base domain
This commit is contained in:
6
main.go
6
main.go
@@ -134,6 +134,12 @@ func fixScheme(u *url.URL) {
|
||||
func toWhitelist(okay []string, host string) bool {
|
||||
host = strings.Split(host, ":")[0]
|
||||
host = strings.Replace(host, "www.", "", -1)
|
||||
host = strings.Replace(host, "http://", "", -1)
|
||||
host = strings.Replace(host, "https://", "", -1)
|
||||
hosts := strings.Split(host, ".")
|
||||
if len(hosts) > 1 {
|
||||
host = hosts[len(hosts)-2] + "." + hosts[len(hosts)-1]
|
||||
}
|
||||
for i := range okay {
|
||||
if strings.Contains(okay[i], host) {
|
||||
return true
|
||||
|
||||
Reference in New Issue
Block a user