Skip to content

Commit

Permalink
Ignore case when parsing PHP versions
Browse files Browse the repository at this point in the history
  • Loading branch information
jalan authored and autarch committed Jun 1, 2021
1 parent 38fd203 commit 1c4c8c9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 3 additions & 0 deletions pkg/version/php.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions pkg/version/php_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 1c4c8c9

Please sign in to comment.