From a0e780edeb270fa8d4a2a7f007a6a4a2b20308ed Mon Sep 17 00:00:00 2001 From: martijnvdp Date: Mon, 22 May 2023 13:11:41 +0200 Subject: [PATCH] allow underscore in version --- version.go | 4 ++-- version_test.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/version.go b/version.go index e87df69..f2447dd 100644 --- a/version.go +++ b/version.go @@ -19,8 +19,8 @@ var ( // of a version. const ( VersionRegexpRaw string = `v?([0-9]+(\.[0-9]+)*?)` + - `(-([0-9]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)|(-?([A-Za-z\-~]+[0-9A-Za-z\-~]*(\.[0-9A-Za-z\-~]+)*)))?` + - `(\+([0-9A-Za-z\-~]+(\.[0-9A-Za-z\-~]+)*))?` + + `(-([0-9]+[0-9A-Za-z\-~_]*(\.[0-9A-Za-z\-~_]+)*)|(-?([A-Za-z\-~_]+[0-9A-Za-z\-~_]*(\.[0-9A-Za-z\-~_]+)*)))?` + + `(\+([0-9A-Za-z\-~_]+(\.[0-9A-Za-z\-~_]+)*))?` + `?` // SemverRegexpRaw requires a separator between version and prerelease diff --git a/version_test.go b/version_test.go index 08cbf01..ff73e93 100644 --- a/version_test.go +++ b/version_test.go @@ -25,6 +25,7 @@ func TestNewVersion(t *testing.T) { {"1.2.0-x.Y.0+metadata", false}, {"1.2.0-x.Y.0+metadata-width-hyphen", false}, {"1.2.3-rc1-with-hyphen", false}, + {"1.2.3-rc2-with_underscore", false}, {"1.2.3.4", false}, {"1.2.0.4-x.Y.0+metadata", false}, {"1.2.0.4-x.Y.0+metadata-width-hyphen", false},