]> BookStack Code Mirror - bookstack/commitdiff
Added test to cover multi-byte slugs
authorDan Brown <redacted>
Sat, 11 Nov 2017 16:15:08 +0000 (16:15 +0000)
committerDan Brown <redacted>
Sat, 11 Nov 2017 16:15:08 +0000 (16:15 +0000)
Also removed check for 'mb_' functions since mbstring is a dependancy

app/Repos/EntityRepo.php
tests/Entity/EntityTest.php

index 25d229be13512ec055ce40fd586f5c35b19f1a0c..944c0bcfc2c9b71fdcc71c1920c601c92d911c33 100644 (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;
index 07f1926c5b94f212e3f6064e41d5dccf834decd0..3f23475a0a18b8e8d8edae47ad779b24d2b5268e 100644 (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);
+    }
+
+
 }