Skip to content

Commit 8b0e31b

Browse files
author
Aaron Schlesinger
committed
fix(pkg/cleaner): return string even if it doesn't have suffix
1 parent 398135f commit 8b0e31b

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

pkg/cleaner/cleaner.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ func stripSuffixes(strs []string, suffix string) []string {
6464
idx := strings.LastIndex(str, suffix)
6565
if idx >= 0 {
6666
ret[i] = str[:idx]
67+
} else {
68+
ret[i] = str
6769
}
6870
}
6971
return ret

pkg/cleaner/cleaner_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ func TestLocalDirs(t *testing.T) {
6363
}
6464

6565
func TestStripSuffixes(t *testing.T) {
66-
strs := []string{"a.git", "b.git", "c.git"}
66+
strs := []string{"a.git", "b.git", "c.git", "d"}
6767
newStrs := stripSuffixes(strs, dotGitSuffix)
68+
assert.Equal(t, len(newStrs), len(strs), "number of strings")
6869
for _, str := range newStrs {
6970
assert.False(t, strings.HasSuffix(str, dotGitSuffix), "string %s has suffix %s", str, dotGitSuffix)
7071
}

0 commit comments

Comments
 (0)