Correctly mark pypi package name specs with multiple specifiers as remote libraries

This commit is contained in:
Andrew Nester 2024-08-27 15:25:17 +02:00
parent edc08149d3
commit a0c29c9c27
No known key found for this signature in database
GPG Key ID: 12BC628A44B7DA57
2 changed files with 7 additions and 0 deletions

View File

@ -77,6 +77,11 @@ func IsLibraryLocal(dep string) bool {
var packageRegex = regexp.MustCompile(`^[a-zA-Z0-9\-_]+\s?(\[.*\])?\s?((==|!=|<=|>=|~=|==|>|<)\s?\d+(\.\d+){0,2}(\.\*)?)?$`)
func isPackage(name string) bool {
// If the name contains comma, it's a package name with miultiple version specifiers
if strings.Contains(name, ",") {
return true
}
if packageRegex.MatchString(name) {
return true
}

View File

@ -62,6 +62,8 @@ func TestIsLibraryLocal(t *testing.T) {
{path: "beautifulsoup4 ~= 4.12.3", expected: false},
{path: "beautifulsoup4[security, tests]", expected: false},
{path: "beautifulsoup4[security, tests] ~= 4.12.3", expected: false},
{path: "beautifulsoup4>=1.0.0,<2.0.0", expected: false},
{path: "beautifulsoup4>=1.0.0,~=1.2.0,<2.0.0", expected: false},
{path: "https://github.com/pypa/pip/archive/22.0.2.zip", expected: false},
{path: "pip @ https://github.com/pypa/pip/archive/22.0.2.zip", expected: false},
{path: "requests [security] @ https://github.com/psf/requests/archive/refs/heads/main.zip", expected: false},