Skip to content

Commit 54c42a0

Browse files
committed
fix(proctype): Change the regex used for validating proctypes
1 parent 50451f8 commit 54c42a0

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

cmd/ps.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ func parseType(target string, appID string) (string, string) {
142142

143143
func parsePsTargets(targets []string) (map[string]int, error) {
144144
targetMap := make(map[string]int)
145-
regex := regexp.MustCompile("^([a-z0-9]+)=([0-9]+)$")
145+
regex := regexp.MustCompile(`^([a-zA-Z0-9]+(\-[a-zA-Z0-9]+)*)=([0-9]+)$`)
146146
var err error
147147

148148
for _, target := range targets {
149149
if regex.MatchString(target) {
150150
captures := regex.FindStringSubmatch(target)
151-
targetMap[captures[1]], err = strconv.Atoi(captures[2])
151+
targetMap[captures[1]], err = strconv.Atoi(captures[3])
152152

153153
if err != nil {
154154
return nil, err

cmd/ps_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,8 @@ func TestParsePsTargets(t *testing.T) {
120120
{[]string{"test=a"}, true, nil, "'test=a' does not match the pattern 'type=num', ex: web=2\n"},
121121
{[]string{"test="}, true, nil, "'test=' does not match the pattern 'type=num', ex: web=2\n"},
122122
{[]string{"test=2"}, false, map[string]int{"test": 2}, ""},
123+
{[]string{"test-proc=2"}, false, map[string]int{"test-proc": 2}, ""},
124+
{[]string{"Test1=2"}, false, map[string]int{"Test1": 2}, ""},
123125
}
124126

125127
for _, check := range cases {

0 commit comments

Comments
 (0)