From a34c3c85fd81fa357402ca2e8a7c02ffb8aa72bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Serv=C3=A9n=20Mar=C3=ADn?= Date: Mon, 8 Jun 2020 16:59:34 +0200 Subject: [PATCH] pkg/ui: simplify SanitizePrefix func (#2733) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit simplifies the SanitizePrefix func to remove an unecessary call to `strings.HasSuffix`. The `strings.TrimSuffix` func internally calls `strings.HasSuffix`, so there is an unneeded, extra call. Signed-off-by: Lucas Servén Marín --- pkg/ui/ui.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/pkg/ui/ui.go b/pkg/ui/ui.go index 08619d7804..49641ce945 100644 --- a/pkg/ui/ui.go +++ b/pkg/ui/ui.go @@ -189,10 +189,7 @@ func SanitizePrefix(prefix string) (string, error) { // Remove double slashes, convert to absolute path. sanitizedPrefix := strings.TrimPrefix(path.Clean(u.Path), ".") - - if strings.HasSuffix(sanitizedPrefix, "/") { - sanitizedPrefix = strings.TrimSuffix(sanitizedPrefix, "/") - } + sanitizedPrefix = strings.TrimSuffix(sanitizedPrefix, "/") return sanitizedPrefix, nil }