make host name parsing case-insensitive

Signed-off-by: Ashish Amarnath <ashish.amarnath@broadcom.com>

Co-authored-by: Ryan Richard <richardry@vmware.com>
This commit is contained in:
Ashish Amarnath
2024-07-29 14:05:07 -07:00
parent dd80627dfa
commit 7c7f0fdae3
2 changed files with 26 additions and 10 deletions

View File

@@ -65,7 +65,8 @@ func Parse(endpoint string, defaultPort uint16) (HostPort, error) {
// Check if the host part is a IPv4 or IPv6 address or a valid hostname according to RFC 1123.
switch {
case len(validation.IsValidIP(field.NewPath("UNKNOWN_PATH"), host)) == 0:
case len(validation.IsDNS1123Subdomain(host)) == 0:
// the host name should be case-insensitive.
case len(validation.IsDNS1123Subdomain(strings.ToLower(host))) == 0:
default:
return HostPort{}, fmt.Errorf("host %q is not a valid hostname or IP address", host)
}