registry: trimV1Address(): simplify trimming trailing slash

strings.TrimSuffix() does exactly the same as this code, but is
a bit more readable.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2021-10-05 21:12:10 +02:00
parent 542edf0c21
commit 4a52c46e37
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -77,10 +77,7 @@ func trimV1Address(address string) (string, error) {
apiVersionStr string apiVersionStr string
) )
if strings.HasSuffix(address, "/") { address = strings.TrimSuffix(address, "/")
address = address[:len(address)-1]
}
chunks = strings.Split(address, "/") chunks = strings.Split(address, "/")
apiVersionStr = chunks[len(chunks)-1] apiVersionStr = chunks[len(chunks)-1]
if apiVersionStr == "v1" { if apiVersionStr == "v1" {