From 9af61d9fe977e3d6bb752b8903b7b8d9674c6e80 Mon Sep 17 00:00:00 2001 From: Niko Sams Date: Thu, 26 Mar 2015 08:33:59 +0100 Subject: [PATCH] Support extjs version format, eg. 4.2.1-883 --- Kwf/ComposerExtraAssets/VersionMatcher.php | 14 ++++++++++++-- tests/VersionMatcherTest.php | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Kwf/ComposerExtraAssets/VersionMatcher.php b/Kwf/ComposerExtraAssets/VersionMatcher.php index 5c445fa..4d2aff4 100644 --- a/Kwf/ComposerExtraAssets/VersionMatcher.php +++ b/Kwf/ComposerExtraAssets/VersionMatcher.php @@ -24,9 +24,12 @@ public static function matchVersions($version1, $version2) return $version1; } + $v1 = self::_normalizeVersion($version1); + $v2 = self::_normalizeVersion($version2); + try { - $v1 = Constraint::parse($version1); - $v2 = Constraint::parse($version2); + $v1 = Constraint::parse($v1); + $v2 = Constraint::parse($v2); } catch (\UnexpectedValueException $e) { return false; } @@ -39,4 +42,11 @@ public static function matchVersions($version1, $version2) return false; } } + private static function _normalizeVersion($v) + { + if (preg_match('#^(\d+\.\d+\.\d+)-(\d+)$#', $v, $m)) { + $v = $m[1].'.'.$m[2]; + } + return $v; + } } diff --git a/tests/VersionMatcherTest.php b/tests/VersionMatcherTest.php index d3aafb6..46cc606 100644 --- a/tests/VersionMatcherTest.php +++ b/tests/VersionMatcherTest.php @@ -19,6 +19,7 @@ public function versions() array('*', '*', '*'), array('foo/foo#master', 'foo/foo#master', 'foo/foo#master'), array(false, '1.0', 'foo/foo#master'), + array('4.2.1-883', '4.2.1-883', '4.2.*'), ); }