mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-29 23:22:34 +01:00
Added test to cover multi-byte slugs
Also removed check for 'mb_' functions since mbstring is a dependancy
This commit is contained in:
parent
e27cbb9dce
commit
f094837709
@ -553,7 +553,7 @@ class EntityRepo
|
||||
*/
|
||||
protected function nameToSlug($name)
|
||||
{
|
||||
$slug = str_replace(' ', '-', function_exists('mb_strtolower') ? mb_strtolower($name) : strtolower($name));
|
||||
$slug = str_replace(' ', '-', mb_strtolower($name));
|
||||
$slug = preg_replace('/[\+\/\\\?\@\}\{\.\,\=\[\]\#\&\!\*\'\;\:\$\%]/', '', $slug);
|
||||
if ($slug === "") $slug = substr(md5(rand(1, 500)), 0, 5);
|
||||
return $slug;
|
||||
|
@ -257,4 +257,15 @@ class EntityTest extends BrowserKitTest
|
||||
->seeInElement('#recently-updated-pages', $page->name);
|
||||
}
|
||||
|
||||
public function test_slug_multi_byte_lower_casing()
|
||||
{
|
||||
$entityRepo = app(EntityRepo::class);
|
||||
$book = $entityRepo->createFromInput('book', [
|
||||
'name' => 'КНИГА'
|
||||
]);
|
||||
|
||||
$this->assertEquals('книга', $book->slug);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user