1
0
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:
Daniel St. Jules
2014-02-17 11:21:06 -05:00
parent 210c928b79
commit 404909ffaa
2 changed files with 3 additions and 0 deletions

View File

@@ -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;
} }

View File

@@ -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àř'),