refactor: replace backport with strings.CutSuffix

The `cutSuffix` function was added to backport the functionality of
`strings.CutSuffix` from Go 1.20. Now that we're using Go 1.25, we can
safely replace our backport with the standard library function. Our
backport was an intact copy/paste of the stdlib implementation, so this
change does not alter any behavior.

Signed-off-by: Babak K. Shandiz <babakks@github.com>
This commit is contained in:
Babak K. Shandiz 2025-10-31 12:20:58 +00:00
parent a73a6937ab
commit 139c2c4f9a
No known key found for this signature in database
GPG key ID: 9472CAEFF56C742E

View file

@ -26,7 +26,7 @@ func Default() string {
// reports whether it found the tenant name.
func TenantName(h string) (string, bool) {
normalizedHostName := ghauth.NormalizeHostname(h)
return cutSuffix(normalizedHostName, "."+tenancyHost)
return strings.CutSuffix(normalizedHostName, "."+tenancyHost)
}
func isGarage(h string) bool {
@ -96,11 +96,3 @@ func HostPrefix(hostname string) string {
}
return fmt.Sprintf("https://%s/", hostname)
}
// Backport strings.CutSuffix from Go 1.20.
func cutSuffix(s, suffix string) (string, bool) {
if !strings.HasSuffix(s, suffix) {
return s, false
}
return s[:len(s)-len(suffix)], true
}