]> BookStack Code Mirror - bookstack/commitdiff
Added Illuminate\Support\Str::slug to generate slug from text to improve the creation...
authorAntonio Cortés (DrZippie) <redacted>
Thu, 25 Jun 2020 16:08:13 +0000 (18:08 +0200)
committerAntonio Cortés (DrZippie) <redacted>
Thu, 25 Jun 2020 16:08:13 +0000 (18:08 +0200)
app/Entities/SlugGenerator.php

index 459a5264a4228148426f7a1174f96da09a32847e..e8bc556abefa102153b64953a6dc76c89784e206 100644 (file)
@@ -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 = preg_replace('/\s{2,}/', ' ', $slug);
-        $slug = str_replace(' ', '-', $slug);
+        $slug = Str::slug($name);
         if ($slug === "") {
             $slug = substr(md5(rand(1, 500)), 0, 5);
         }
         if ($slug === "") {
             $slug = substr(md5(rand(1, 500)), 0, 5);
         }