Browse Source

Fixed regression in #16817 (#17056)

tags/2.0.16
Bizley 6 years ago committed by Alexander Makarov
parent
commit
de5b903806
  1. 4
      framework/helpers/BaseInflector.php
  2. 3
      tests/framework/helpers/InflectorTest.php

4
framework/helpers/BaseInflector.php

@ -480,8 +480,8 @@ class BaseInflector
$parts = explode($replacement, static::transliterate($string));
$replaced = array_map(function ($element) use ($replacement) {
$element = preg_replace('/[^a-zA-Z0-9=\s—–]+/u', '', $element);
return preg_replace('/[=\s—–]+/u', $replacement, $element);
$element = preg_replace('/[^a-zA-Z0-9=\s—–-]+/u', '', $element);
return preg_replace('/[=\s—–-]+/u', $replacement, $element);
}, $parts);
$string = trim(implode($replacement, $replaced), $replacement);

3
tests/framework/helpers/InflectorTest.php

@ -187,7 +187,8 @@ class InflectorTest extends TestCase
{
$this->assertEquals('dont_replace_replacement', Inflector::slug('dont replace_replacement', '_'));
$this->assertEquals('remove_trailing_replacements', Inflector::slug('_remove trailing replacements_', '_'));
$this->assertEquals('thisrepisrepreplacement', Inflector::slug('this is REP-lacement', 'REP'));
$this->assertEquals('thisrepisreprepreplacement', Inflector::slug('this is REP-lacement', 'REP'));
$this->assertEquals('0_100_kmh', Inflector::slug('0-100 Km/h', '_'));
}
public function testSlugIntl()

Loading…
Cancel
Save