Skip to content

Commit

Permalink
pkg/ui: simplify SanitizePrefix func (#2733)
Browse files Browse the repository at this point in the history
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 <lserven@gmail.com>
  • Loading branch information
squat authored Jun 8, 2020
1 parent ed71a27 commit a34c3c8
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions pkg/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit a34c3c8

Please sign in to comment.