diff --git a/authentication/allowed_hosts_validator.go b/authentication/allowed_hosts_validator.go index 833f862..052882d 100644 --- a/authentication/allowed_hosts_validator.go +++ b/authentication/allowed_hosts_validator.go @@ -66,8 +66,12 @@ func (v *AllowedHostsValidator) SetAllowedHostsErrorCheck(hosts []string) error // IsValidHost returns true if the host is valid. func (v *AllowedHostsValidator) IsUrlHostValid(uri *u.URL) bool { - if uri == nil || uri.Hostname() == "" { + if uri == nil { return false } - return len(v.validHosts) == 0 || v.validHosts[strings.ToLower(uri.Hostname())] + host := uri.Hostname() + if host == "" { + return false + } + return len(v.validHosts) == 0 || v.validHosts[strings.ToLower(host)] }