浏览代码

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>
Sebastiaan van Stijn 3 年之前
父节点
当前提交
4a52c46e37
共有 1 个文件被更改,包括 1 次插入4 次删除
  1. 1 4
      registry/endpoint_v1.go

+ 1 - 4
registry/endpoint_v1.go

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