Skip to content
This repository has been archived by the owner on Feb 1, 2020. It is now read-only.

Pre-release tags with hyphens are truncated #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/Herrera/Version/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static function toComponents($version)
}

if (false !== strpos($version, '-')) {
list($version, $pre) = explode('-', $version);
list($version, $pre) = preg_split('/-/', $version, 1);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning, your limit parameter is incorrect :

<?php
print_r(preg_split('/-/', '1.2.3-pre-release', 1));
?>

The above example will output, and break the unit testing :

Array
(
    [0] => 1.2.3-pre-release
)

But, fix limit to 2 :

<?php
print_r(preg_split('/-/', '1.2.3-pre-release', 2));
?>

The above example will output:

Array
(
    [0] => 1.2.3
    [1] => pre-release
)

Expected return for the need of your pull request


$pre = explode('.', $pre);
}
Expand Down