mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-08-26 12:16:07 +00:00
Added Illuminate\Support\Str::slug to generate slug from text to improve the creation of slugs with non-English characters
This commit is contained in:
parent
71e7dd5894
commit
ca202c1819
@ -1,5 +1,7 @@
|
|||||||
<?php namespace BookStack\Entities;
|
<?php namespace BookStack\Entities;
|
||||||
|
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class SlugGenerator
|
class SlugGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -32,9 +34,7 @@ class SlugGenerator
|
|||||||
*/
|
*/
|
||||||
protected function formatNameAsSlug(string $name): string
|
protected function formatNameAsSlug(string $name): string
|
||||||
{
|
{
|
||||||
$slug = preg_replace('/[\+\/\\\?\@\}\{\.\,\=\[\]\#\&\!\*\'\;\:\$\%]/', '', mb_strtolower($name));
|
$slug = Str::slug($name);
|
||||||
$slug = preg_replace('/\s{2,}/', ' ', $slug);
|
|
||||||
$slug = str_replace(' ', '-', $slug);
|
|
||||||
if ($slug === "") {
|
if ($slug === "") {
|
||||||
$slug = substr(md5(rand(1, 500)), 0, 5);
|
$slug = substr(md5(rand(1, 500)), 0, 5);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user