From 4c0947c55dc7c602934a1da3b3bbeaf0040e42b9 Mon Sep 17 00:00:00 2001 From: Ammar Husain Huk Date: Thu, 11 Jul 2024 15:20:49 +0530 Subject: [PATCH] fix: Made changes as per the comments --- pkg/s3utils/utils.go | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/pkg/s3utils/utils.go b/pkg/s3utils/utils.go index de66fb118..ecdc5c9ce 100644 --- a/pkg/s3utils/utils.go +++ b/pkg/s3utils/utils.go @@ -31,7 +31,6 @@ import ( // Sentinel URL is the default url value which is invalid. var sentinelURL = url.URL{} -var host string // IsValidDomain validates if input string is a valid domain name. func IsValidDomain(host string) bool { @@ -224,11 +223,10 @@ func IsAmazonPrivateLinkEndpoint(endpointURL url.URL) bool { // IsGoogleEndpoint - Match if it is exactly Google cloud storage endpoint. func IsGoogleEndpoint(endpointURL url.URL) bool { - host := HasPortNumber(endpointURL) if endpointURL == sentinelURL { return false } - return host == "storage.googleapis.com" + return endpointURL.Hostname() == "storage.googleapis.com" } // Expects ascii encoded strings - from output of urlEncodePath @@ -410,14 +408,4 @@ func CheckValidObjectName(objectName string) error { return errors.New("Object name cannot be empty") } return CheckValidObjectNamePrefix(objectName) -} - -//checks for port number -func HasPortNumber(endpointURL url.URL) string { - if colonIndex := strings.LastIndex(endpointURL.Host, ":"); colonIndex != -1 { - host = endpointURL.Host[:colonIndex] - } else { - host = endpointURL.Host - } - return host -} +} \ No newline at end of file