Merge pull request #3292 from francoispluchino/fix-format-version-parser
Fix invalid version formatpull/3291/merge
commit
1fff2afa1f
|
@ -122,6 +122,12 @@ class VersionParser
|
|||
} elseif (preg_match('{^v?(\d{4}(?:[.:-]?\d{2}){1,6}(?:[.:-]?\d{1,3})?)'.self::$modifierRegex.'$}i', $version, $matches)) { // match date-based versioning
|
||||
$version = preg_replace('{\D}', '-', $matches[1]);
|
||||
$index = 2;
|
||||
} elseif (preg_match('{^v?(\d{4,})(\.\d+)?(\.\d+)?(\.\d+)?'.self::$modifierRegex.'$}i', $version, $matches)) {
|
||||
$version = $matches[1]
|
||||
.(!empty($matches[2]) ? $matches[2] : '.0')
|
||||
.(!empty($matches[3]) ? $matches[3] : '.0')
|
||||
.(!empty($matches[4]) ? $matches[4] : '.0');
|
||||
$index = 5;
|
||||
}
|
||||
|
||||
// add version modifiers if a version was matched
|
||||
|
|
|
@ -97,6 +97,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
|||
'parses dates w/ .' => array('2010.01.02', '2010-01-02'),
|
||||
'parses dates w/ -' => array('2010-01-02', '2010-01-02'),
|
||||
'parses numbers' => array('2010-01-02.5', '2010-01-02-5'),
|
||||
'parses dates y.m.Y' => array('2010.1.555', '2010.1.555.0'),
|
||||
'parses datetime' => array('20100102-203040', '20100102-203040'),
|
||||
'parses dt+number' => array('20100102203040-10', '20100102203040-10'),
|
||||
'parses dt+patch' => array('20100102-203040-p1', '20100102-203040-patch1'),
|
||||
|
|
Loading…
Reference in New Issue