From 9e6321e500b2c239831027e4d4cda748953ed28e Mon Sep 17 00:00:00 2001 From: Attila Kerekes <439392+keriati@users.noreply.github.com> Date: Fri, 16 Dec 2022 09:26:00 +0000 Subject: [PATCH] fix: Enable tag slug creation from CN characters (#1077) --- app/Http/Controllers/TagController.php | 6 ++---- tests/Unit/helpers/SlugTest.php | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 tests/Unit/helpers/SlugTest.php diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index e5bd0649..d5d95891 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -4,13 +4,11 @@ namespace App\Http\Controllers; use App\Item; use App\User; -use DB; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; -use Illuminate\Http\Response; class TagController extends Controller { @@ -68,7 +66,7 @@ class TagController extends Controller ]); } - $slug = str_slug($request->title, '-'); + $slug = str_slug($request->title, '-', 'en_US'); $current_user = User::currentUser(); @@ -140,7 +138,7 @@ class TagController extends Controller ]); } - $slug = str_slug($request->title, '-'); + $slug = str_slug($request->title, '-', 'en_US'); // set item type to tag $request->merge([ 'url' => $slug, diff --git a/tests/Unit/helpers/SlugTest.php b/tests/Unit/helpers/SlugTest.php new file mode 100644 index 00000000..a12bd8be --- /dev/null +++ b/tests/Unit/helpers/SlugTest.php @@ -0,0 +1,18 @@ +assertEquals('zhong-wen-ce-shi', $tag); + } +}