Skip to content

Commit

Permalink
refactor: remove unneeded index check in favor of just always splitti…
Browse files Browse the repository at this point in the history
…ng (#210)
  • Loading branch information
G-Rath authored Aug 25, 2023
1 parent 8a2a7bf commit 8c048cd
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions pkg/lockfile/parse-pnpm-lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,9 @@ func extractPnpmPackageNameAndVersion(dependencyPath string) (string, string) {
return "", ""
}

underscoreIndex := strings.Index(version, "_")

if underscoreIndex != -1 {
version = strings.Split(version, "_")[0]
}
// peer dependencies in v5 lockfiles are attached to the end of the version
// with an "_", so we always want the first element if an "_" is present
version = strings.Split(version, "_")[0]

return name, version
}
Expand Down

0 comments on commit 8c048cd

Please sign in to comment.