Skip to content

Commit b354082

Browse files
krizalyssebastianbergmann
authored andcommitted
Stripping trailing new line in parser
1 parent c38b460 commit b354082

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Parser.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ class Parser
2222
*/
2323
public function parse($string)
2424
{
25-
$lines = preg_split('(\r\n|\r|\n)', $string);
25+
$lines = preg_split('(\r\n|\r|\n)', $string);
26+
27+
if (!empty($lines) && $lines[count($lines) - 1] == '') {
28+
array_pop($lines);
29+
}
30+
2631
$lineCount = count($lines);
2732
$diffs = array();
2833
$diff = null;

0 commit comments

Comments
 (0)