mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
Merge branch 'master' of git://github.com/drzippie/BookStack into drzippie-master
This commit is contained in:
commit
8bc3e0f31a
@ -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);
|
||||
}
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user