From 0e3d91ff74a9987f075d0d943b0194cc85ea38fa Mon Sep 17 00:00:00 2001 From: Alan Xu Date: Fri, 19 Jan 2024 22:22:37 +0800 Subject: [PATCH] revert(allowed_host_validator.go): revert function IsUrlHostValid revert function IsUrlHostValid --- authentication/allowed_hosts_validator.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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)] }