File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -327,7 +327,7 @@ func expandWildcardVersion(parts [][]string) ([][]string, error) {
327327 for _ , p := range parts {
328328 var newParts []string
329329 for _ , ap := range p {
330- if strings . Contains (ap , "x" ) {
330+ if containsWildcard (ap ) {
331331 opStr , vStr , err := splitComparatorVersion (ap )
332332 if err != nil {
333333 return nil , err
@@ -381,6 +381,12 @@ func expandWildcardVersion(parts [][]string) ([][]string, error) {
381381 return expandedParts , nil
382382}
383383
384+ // containsWildcard returns true iff there's a wildcard in any of the major, minor or patch components
385+ func containsWildcard (v string ) bool {
386+ withoutPrereleaseBuildMeta := strings .Split (strings .Split (v , "+" )[0 ], "-" )[0 ]
387+ return strings .Contains (withoutPrereleaseBuildMeta , "x" )
388+ }
389+
384390func parseComparator (s string ) comparator {
385391 switch s {
386392 case "==" :
Original file line number Diff line number Diff line change @@ -202,6 +202,7 @@ func TestGetWildcardType(t *testing.T) {
202202 {"x" , majorWildcard },
203203 {"1.x" , minorWildcard },
204204 {"1.2.x" , patchWildcard },
205+ {"1.2.3-experimental" , noneWildcard },
205206 {"fo.o.b.ar" , noneWildcard },
206207 }
207208
@@ -387,6 +388,16 @@ func TestParseRange(t *testing.T) {
387388 {"1.2.3" , true },
388389 {"1.2.4" , false },
389390 }},
391+ {"1.2.3-experimental.2" , []tv {
392+ {"1.2.3-experimental.1" , false },
393+ {"1.2.3-experimental.2" , true },
394+ {"1.2.3-experimental.3" , false },
395+ }},
396+ {"1.2.3+experimental.2" , []tv {
397+ {"1.2.3+experimental.1" , false },
398+ {"1.2.3+experimental.2" , true },
399+ {"1.2.3+experimental.3" , false },
400+ }},
390401 {"=1.2.3" , []tv {
391402 {"1.2.2" , false },
392403 {"1.2.3" , true },
You can’t perform that action at this time.
0 commit comments