File tree Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Expand file tree Collapse file tree 2 files changed +29
-5
lines changed Original file line number Diff line number Diff line change @@ -327,12 +327,12 @@ 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" ) {
331- 				opStr , vStr , err  :=  splitComparatorVersion (ap )
332- 				if  err  !=  nil  {
333- 					return  nil , err 
334- 				}
330+ 			opStr , vStr , err  :=  splitComparatorVersion (ap )
331+ 			if  err  !=  nil  {
332+ 				return  nil , err 
333+ 			}
335334
335+ 			if  containsWildcard (ap ) {
336336				versionWildcardType  :=  getWildcardType (vStr )
337337				flatVersion  :=  createVersionFromWildcard (vStr )
338338
@@ -381,6 +381,16 @@ func expandWildcardVersion(parts [][]string) ([][]string, error) {
381381	return  expandedParts , nil 
382382}
383383
384+ // containsWildcard returns true if there's a wildcard in any of the major, minor or patch components 
385+ func  containsWildcard (v  string ) bool  {
386+ 	return  strings .Contains (trimIdentifiers (v ), ".x" )
387+ }
388+ 
389+ // trimIdentifiers removes any pre-release and build metadata from a version 
390+ func  trimIdentifiers (v  string ) string  {
391+   return  strings .Split (strings .Split (v , "+" )[0 ], "-" )[0 ]
392+ }
393+ 
384394func  parseComparator (s  string ) comparator  {
385395	switch  s  {
386396	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-x" , noneWildcard },
205206		{"fo.o.b.ar" , noneWildcard },
206207	}
207208
@@ -387,6 +388,19 @@ func TestParseRange(t *testing.T) {
387388			{"1.2.3" , true },
388389			{"1.2.4" , false },
389390		}},
391+ 		{"1.2.3-x.x" , []tv {
392+ 			{"1.2.3-x.y" , false },
393+ 			{"1.2.3-x.x" , true },
394+ 		}},
395+ 		{"1.2.3+x.x" , []tv {
396+ 			{"1.2.3+x.y" , false },
397+ 			{"1.2.3+x.x" , true },
398+ 		}},
399+ 		{"1.2.3-x.x+x.x" , []tv {
400+ 			{"1.2.3-x.x+x.y" , false },
401+ 			{"1.2.3-x.y+x.x" , false },
402+ 			{"1.2.3-x.x+x.x" , true },
403+ 		}},
390404		{"=1.2.3" , []tv {
391405			{"1.2.2" , false },
392406			{"1.2.3" , true },
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments