1
0
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:
Dan Brown 2017-11-11 16:15:08 +00:00
parent e27cbb9dce
commit f094837709
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 12 additions and 1 deletions

View File

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

View File

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