From 1c4c8c9a2e604dd46a5b9e9e294538daefed40c6 Mon Sep 17 00:00:00 2001 From: Jason Alan Palmer Date: Tue, 1 Jun 2021 15:00:26 -0600 Subject: [PATCH] Ignore case when parsing PHP versions --- Changes.md | 5 +++++ pkg/version/php.go | 3 +++ pkg/version/php_test.go | 7 ++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Changes.md b/Changes.md index bd5087a..47f046c 100644 --- a/Changes.md +++ b/Changes.md @@ -1,3 +1,8 @@ +## v0.0.9 2021-06-01 + +* Ignore case when parsing PHP versions. + + ## v0.0.8 2021-05-27 * Fix several bugs in SemVer parsing. diff --git a/pkg/version/php.go b/pkg/version/php.go index b4832f6..a05230c 100644 --- a/pkg/version/php.go +++ b/pkg/version/php.go @@ -137,6 +137,9 @@ func normalizePHP(version string) (string, error) { // Extra whitespace is tolerated version = strings.TrimSpace(version) + // Case doesn't matter + version = strings.ToLower(version) + // Remove aliasing matches := phpAliasRegex.FindStringSubmatch(version) if len(matches) > 1 { diff --git a/pkg/version/php_test.go b/pkg/version/php_test.go index 23269fd..f357eec 100644 --- a/pkg/version/php_test.go +++ b/pkg/version/php_test.go @@ -23,6 +23,7 @@ var normalizePHPTests = [][]string{ {"1.0-dev", "1.0.0.0-dev"}, {"1.0.0 ", "1.0.0.0"}, {"1.0.0", "1.0.0.0"}, + {"1.0.0-BeTA", "1.0.0.0-beta"}, {"1.0.0+foo as 2.0", "1.0.0.0"}, {"1.0.0+foo", "1.0.0.0"}, {"1.0.0+foo@dev", "1.0.0.0"}, @@ -137,9 +138,9 @@ func TestInvalidPHPVersions(t *testing.T) { } var testParsePHPEqualInputs = [][]string{ - {"0", "0.0", "0.0.0", "0000", "0.0.0.0-stable"}, + {"0", "0.0", "0.0.0", "0000", "0.0.0.0-stable", "0.0.0.0-STABLE"}, {"000000", "0000000", "00000000"}, - {"1a", "1alpha"}, + {"1a", "1alpha", "1ALPHA"}, {"2.b", "2-beta", "2-b", "2.beta"}, {"3RC", "3.0.0.0-rc"}, {"4dev", "4.dev", "4-dev"}, @@ -208,7 +209,7 @@ var testParsePHPOrderInputs = []string{ "2010-01-02", "2010.01.02.dev", "2010.01.02.a", - "2010.01.02-stable", + "2010.01.02-STABLE", "2010.01.02.p", "2010.01.02.p0", "2010.01.02.p1",