From d1ef55dc9cac90302aa4ba72ded1913ae276e4d0 Mon Sep 17 00:00:00 2001 From: martijnvdp Date: Tue, 28 Dec 2021 15:00:36 +0100 Subject: [PATCH] allow underscor 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 116a744..fd76efb 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 9fa34f6..3013b03 100644 --- a/version_test.go +++ b/version_test.go @@ -23,6 +23,7 @@ func TestNewVersion(t *testing.T) { {"1.2.0-x.Y.0+metadata", false}, {"1.2.0-x.Y.0+metadata-width-hypen", false}, {"1.2.3-rc1-with-hypen", 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-hypen", false},