From 9ed9b90c331d8de32932ad44e3198fb7ac587185 Mon Sep 17 00:00:00 2001 From: Andrew Nester Date: Wed, 28 Aug 2024 13:12:33 +0200 Subject: [PATCH] use regex instead --- bundle/libraries/local_path.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/bundle/libraries/local_path.go b/bundle/libraries/local_path.go index 9fff715b7..6724c578b 100644 --- a/bundle/libraries/local_path.go +++ b/bundle/libraries/local_path.go @@ -74,14 +74,9 @@ func IsLibraryLocal(dep string) bool { // \[.*\])?: Optionally matches any extras specified in square brackets, e.g., [security]. // ((==|!=|<=|>=|~=|>|<)\d+(\.\d+){0,2}(\.\*)?)?: Optionally matches version specifiers, supporting various operators (==, !=, etc.) followed by a version number (e.g., 2.25.1). // Spec for package name and version specifier: https://pip.pypa.io/en/stable/reference/requirement-specifiers/ -var packageRegex = regexp.MustCompile(`^[a-zA-Z0-9\-_]+\s?(\[.*\])?\s?((==|!=|<=|>=|~=|==|>|<)\s?\d+(\.\d+){0,2}(\.\*)?)?$`) +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 }