Skip to content

Commit eafcaad

Browse files
committed
feat(pnpm): pnpm v9, version indicator detect
1 parent a57bbb9 commit eafcaad

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

module/pnpm/version_indicator.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"github.com/murphysecurity/murphysec/module/pnpm/shared"
66
"regexp"
7+
"strconv"
78
)
89

910
type lockfileVersionIndicator struct {
@@ -19,11 +20,10 @@ func parseLockfileVersion(data []byte) (string, error) {
1920
}
2021

2122
func matchLockfileVersion(s string) int {
22-
if regexp.MustCompile(`^v?5\.`).MatchString(s) {
23-
return 5
24-
}
25-
if regexp.MustCompile(`^v?6\.`).MatchString(s) {
26-
return 6
23+
d := regexp.MustCompile(`^v?(\d+)(\.|$)`).FindStringSubmatch(s)
24+
if d != nil {
25+
n, _ := strconv.Atoi(d[1])
26+
return n
2727
}
2828
return 0
2929
}

0 commit comments

Comments
 (0)