Skip to content

Commit

Permalink
fix: Made changes as per the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Ammar Husain Huk committed Jul 11, 2024
1 parent 11b4512 commit 4c0947c
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions pkg/s3utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}

Check failure on line 411 in pkg/s3utils/utils.go

View workflow job for this annotation

GitHub Actions / Test on Go 1.22.x and ubuntu-latest

File is not `goimports`-ed (goimports)

0 comments on commit 4c0947c

Please sign in to comment.