Skip to content

Commit cefe9bc

Browse files
committed
index checks
1 parent b9bd55c commit cefe9bc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

testaddon.go

+7
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ func getUniqueDir(path string) (string, error) {
1818
return "", fmt.Errorf("path (%s) does not contain 'test-results' folder", path)
1919
}
2020

21+
if i+1 > len(parts) {
22+
return "", fmt.Errorf("get variant name: out of index error")
23+
}
24+
2125
variant := parts[i+1]
2226
variant = strings.TrimPrefix(variant, "test")
2327
variant = strings.TrimSuffix(variant, "UnitTest")
@@ -26,6 +30,9 @@ func getUniqueDir(path string) (string, error) {
2630
runes[0] = unicode.ToLower(runes[0])
2731
variant = string(runes)
2832

33+
if i < 2 {
34+
return "", fmt.Errorf("get module name: out of index error")
35+
}
2936
module := parts[i-2]
3037

3138
return module + "-" + variant, nil

0 commit comments

Comments
 (0)