1
0
Fork 0

Version parser stability regexp update

pull/886/head
Alexey Prilipko 2012-07-09 08:47:40 +11:00
parent 490b2c0295
commit 75d3d57117
2 changed files with 14 additions and 3 deletions

View File

@ -24,7 +24,7 @@ use Composer\Package\LinkConstraint\VersionConstraint;
*/
class VersionParser
{
private static $modifierRegex = '[.-]?(?:(beta|RC|alpha|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?';
private static $modifierRegex = '[._-]?(?:(beta|b|RC|alpha|a|patch|pl|p)(?:[.-]?(\d+))?)?([.-]?dev)?';
/**
* Returns the stability of a version
@ -45,8 +45,16 @@ class VersionParser
return 'dev';
}
if (!empty($match[1]) && ($match[1] === 'beta' || $match[1] === 'alpha' || $match[1] === 'RC')) {
return $match[1];
if (!empty($match[1])) {
if ('beta' === $match[1] || 'b' === $match[1]) {
return 'beta';
}
if ('alpha' === $match[1] || 'a' === $match[1]) {
return 'alpha';
}
if ('RC' === $match[1]) {
return 'RC';
}
}
return 'stable';

View File

@ -238,6 +238,9 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
array('stable', '3.1.2-patch'),
array('alpha', '3.1.2-alpha5'),
array('beta', '3.1.2-beta'),
array('beta', '2.0b1'),
array('alpha', '1.2.0a1'),
array('alpha', '1.2_a1'),
);
}
}