diff --git a/src/Liquid/StandardFilters.php b/src/Liquid/StandardFilters.php index 433bd41..76a9f7d 100644 --- a/src/Liquid/StandardFilters.php +++ b/src/Liquid/StandardFilters.php @@ -621,6 +621,10 @@ public static function split($input, $pattern) return []; } + if ($pattern === '') { + return mb_str_split($input); + } + return explode($pattern, $input); } diff --git a/tests/Liquid/StandardFiltersTest.php b/tests/Liquid/StandardFiltersTest.php index b8efb7a..8bafd46 100644 --- a/tests/Liquid/StandardFiltersTest.php +++ b/tests/Liquid/StandardFiltersTest.php @@ -881,6 +881,21 @@ public function testSplit() array('123', '123', '123'), '0' ), + array( + 'phrase', + array('p', 'h', 'r', 'a', 's', 'e'), + '' + ), + array( + 'phrase', + array('phrase'), + null + ), + array( + '123 123 123', + array('123', '123', '123'), + ' ' + ), ); foreach ($data as $item) {