Skip to content

Commit d1f3e8a

Browse files
committed
check number of context pieces
Signed-off-by: Grant Linville <[email protected]>
1 parent 1d9866e commit d1f3e8a

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

pkg/credentials/helper.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,14 @@ func (h *HelperStore) GetAll() (map[string]types.AuthConfig, error) {
6868
return nil, err
6969
}
7070

71-
possiblePortNumber := strings.Split(ctx, ":")[len(strings.Split(ctx, ":"))-1]
72-
if regexp.MustCompile(`\d+$`).MatchString(possiblePortNumber) {
73-
// port number confirmed
74-
toolName = toolName + ":" + possiblePortNumber
75-
ctx = strings.TrimSuffix(ctx, ":"+possiblePortNumber)
71+
contextPieces := strings.Split(ctx, ":")
72+
if len(contextPieces) > 1 {
73+
possiblePortNumber := contextPieces[len(contextPieces)-1]
74+
if regexp.MustCompile(`\d+$`).MatchString(possiblePortNumber) {
75+
// port number confirmed
76+
toolName = toolName + ":" + possiblePortNumber
77+
ctx = strings.TrimSuffix(ctx, ":"+possiblePortNumber)
78+
}
7679
}
7780

7881
newCredAddresses[toolNameWithCtx(toolName, ctx)] = val

0 commit comments

Comments
 (0)