Skip to content

Commit dfda342

Browse files
committed
cli/command/formatter: StripNamePrefix only strip "/" prefix
This code was assuming the API always returns container names with a "/" prefix. While this is currently correct, we may at some point stop doing so. This patch changes the code to only trim "/" as prefix and not any other character. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent b5efd66 commit dfda342

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

cli/command/formatter/container.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,12 @@ func (c *ContainerContext) Names() string {
155155
return strings.Join(names, ",")
156156
}
157157

158-
// StripNamePrefix removes prefix from string, typically container names as returned by `ContainersList` API
158+
// StripNamePrefix removes any "/" prefix from container names returned
159+
// by the "ContainersList" API.
159160
func StripNamePrefix(ss []string) []string {
160161
sss := make([]string, len(ss))
161162
for i, s := range ss {
162-
sss[i] = s[1:]
163+
sss[i] = strings.TrimPrefix(s, "/")
163164
}
164165
return sss
165166
}

0 commit comments

Comments
 (0)