diff --git a/constraints_test.go b/constraints_test.go index a45714d..9ee287f 100644 --- a/constraints_test.go +++ b/constraints_test.go @@ -53,6 +53,12 @@ func TestParseConstraint(t *testing.T) { includeMin: true, includeMax: false, }, false}, + {"^1.1.0-12-abc123", rangeConstraint{ + min: Version{major: 1, minor: 1, patch: 0, pre: "12-abc123"}, + max: newV(2, 0, 0), + includeMin: true, + includeMax: false, + }, false}, } for _, tc := range tests { @@ -70,7 +76,7 @@ func TestParseConstraint(t *testing.T) { } if !constraintEq(tc.c, c) { - t.Errorf("Incorrect version found on %s", tc.in) + t.Errorf("%q produced constraint %q, but expected %q", tc.in, c, tc.c) } } } diff --git a/parse.go b/parse.go index d6afa6c..f40537d 100644 --- a/parse.go +++ b/parse.go @@ -7,6 +7,9 @@ import ( ) func rewriteRange(i string) string { + if versionRegex.MatchString(i) { + return i + } m := constraintRangeRegex.FindAllStringSubmatch(i, -1) if m == nil { return i