Skip to content

Commit

Permalink
Fix local package regexp for packages with hyphen in name (#1596)
Browse files Browse the repository at this point in the history
Currently there is a bug where because the regexp is liberal enough to allow either _ or - to delimit the break between name and version, a package with dash will fail.

So for instance, a package like

my-package_1.2.3

Will have a name of "my" and a version of "package_1.2.3".

Not wanting to change this behaviour by simply changing the regex to only accept _ as a delimeter, I have changed the regex to split at the *last* match.
  • Loading branch information
radiosilence authored Mar 17, 2024
1 parent 0b7e8bb commit e866995
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lepton/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
// PackageSysRootFolderName is the name of package root folder
const PackageSysRootFolderName = "sysroot"

var packageRegex = regexp.MustCompile(`(?P<packageName>[A-Za-z]+)[_-](?P<version>\S+)`)
var packageRegex = regexp.MustCompile(`(?P<packageName>[A-Za-z-]+)[_-](?P<version>\S+)`)

// PackageList contains a list of known packages.
type PackageList struct {
Expand Down

0 comments on commit e866995

Please sign in to comment.