Эх сурвалжийг харах

Minor improvements to VersionParser

Jordi Boggiano 13 жил өмнө
parent
commit
da6566b343

+ 3 - 3
src/Composer/Package/Version/VersionParser.php

@@ -49,9 +49,9 @@ class VersionParser
         // add version modifiers if a version was matched
         // add version modifiers if a version was matched
         if (isset($index)) {
         if (isset($index)) {
             if (!empty($matches[$index])) {
             if (!empty($matches[$index])) {
-                $mod = array('p', 'pl', 'rc');
-                $modNormalized = array('patch', 'patch', 'RC');
-                $version .= '-'.str_replace($mod, $modNormalized, strtolower($matches[$index]))
+                $mod = array('{^pl?$}', '{^rc$}');
+                $modNormalized = array('patch', 'RC');
+                $version .= '-'.preg_replace($mod, $modNormalized, strtolower($matches[$index]))
                     . (!empty($matches[$index+1]) ? $matches[$index+1] : '');
                     . (!empty($matches[$index+1]) ? $matches[$index+1] : '');
             }
             }
 
 

+ 2 - 0
tests/Composer/Test/Package/Version/VersionParserTest.php

@@ -35,6 +35,8 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
             'parses state'      => array('1.0.0RC1dev',         '1.0.0.0-RC1-dev'),
             'parses state'      => array('1.0.0RC1dev',         '1.0.0.0-RC1-dev'),
             'CI parsing'        => array('1.0.0-rC15-dev',      '1.0.0.0-RC15-dev'),
             'CI parsing'        => array('1.0.0-rC15-dev',      '1.0.0.0-RC15-dev'),
             'delimiters'        => array('1.0.0.RC.15-dev',     '1.0.0.0-RC15-dev'),
             'delimiters'        => array('1.0.0.RC.15-dev',     '1.0.0.0-RC15-dev'),
+            'RC uppercase'      => array('1.0.0-rc1',           '1.0.0.0-RC1'),
+            'patch replace'     => array('1.0.0.pl3-dev',       '1.0.0.0-patch3-dev'),
             'forces w.x.y.z'    => array('1.0-dev',             '1.0.0.0-dev'),
             'forces w.x.y.z'    => array('1.0-dev',             '1.0.0.0-dev'),
             'forces w.x.y.z'    => array('0',                   '0.0.0.0'),
             'forces w.x.y.z'    => array('0',                   '0.0.0.0'),
             'parses long'       => array('10.4.13-beta',        '10.4.13.0-beta'),
             'parses long'       => array('10.4.13-beta',        '10.4.13.0-beta'),