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:
parent
a73a6937ab
commit
139c2c4f9a
1 changed files with 1 additions and 9 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue