mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-15 09:44:14 +02:00
Fixes #19: Handle consecutive invalid chars in slugify
This commit is contained in:
@@ -713,6 +713,7 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
|
|||||||
$stringy->toAscii());
|
$stringy->toAscii());
|
||||||
$stringy->str = $stringy->collapseWhitespace()->str;
|
$stringy->str = $stringy->collapseWhitespace()->str;
|
||||||
$stringy->str = str_replace(' ', $replacement, strtolower($stringy));
|
$stringy->str = str_replace(' ', $replacement, strtolower($stringy));
|
||||||
|
$stringy->str = preg_replace("/[$replacement]+/u", $replacement, $stringy);
|
||||||
|
|
||||||
return $stringy;
|
return $stringy;
|
||||||
}
|
}
|
||||||
|
@@ -333,6 +333,8 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
|
|||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array('foo-bar', ' foo bar '),
|
array('foo-bar', ' foo bar '),
|
||||||
|
array('foo-bar', 'foo -.-"-...bar'),
|
||||||
|
array('another-foo-bar', 'another..& foo -.-"-...bar'),
|
||||||
array('foo-dbar', " Foo d'Bar "),
|
array('foo-dbar', " Foo d'Bar "),
|
||||||
array('a-string-with-dashes', 'A string-with-dashes'),
|
array('a-string-with-dashes', 'A string-with-dashes'),
|
||||||
array('using-strings-like-foo-bar', 'Using strings like fòô bàř'),
|
array('using-strings-like-foo-bar', 'Using strings like fòô bàř'),
|
||||||
|
Reference in New Issue
Block a user