Merge branch 'master' of git://github.com/drzippie/BookStack into drzippie-master

This commit is contained in:
Dan Brown 2020-06-27 17:11:11 +01:00
commit 8bc3e0f31a
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9
2 changed files with 12 additions and 7 deletions

View File

@ -1,5 +1,7 @@
<?php namespace BookStack\Entities;
use Illuminate\Support\Str;
class SlugGenerator
{
@ -32,9 +34,7 @@ class SlugGenerator
*/
protected function formatNameAsSlug(string $name): string
{
$slug = preg_replace('/[\+\/\\\?\@\}\{\.\,\=\[\]\#\&\!\*\'\;\:\$\%]/', '', mb_strtolower($name));
$slug = preg_replace('/\s{2,}/', ' ', $slug);
$slug = str_replace(' ', '-', $slug);
$slug = Str::slug($name);
if ($slug === "") {
$slug = substr(md5(rand(1, 500)), 0, 5);
}

View File

@ -273,15 +273,20 @@ class EntityTest extends BrowserKitTest
->seeInElement('#recently-updated-pages', $page->name);
}
public function test_slug_multi_byte_lower_casing()
public function test_slug_multi_byte_url_safe()
{
$book = $this->newBook([
'name' => 'КНИГА'
'name' => 'информация'
]);
$this->assertEquals('книга', $book->slug);
}
$this->assertEquals('informatsiya', $book->slug);
$book = $this->newBook([
'name' => '¿Qué?'
]);
$this->assertEquals('que', $book->slug);
}
public function test_slug_format()
{