fix: Enable tag slug creation from CN characters (#1077)

This commit is contained in:
Attila Kerekes 2022-12-16 09:26:00 +00:00 committed by GitHub
parent 0d9850c1c7
commit 9e6321e500
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 4 deletions

View file

@ -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,

View file

@ -0,0 +1,18 @@
<?php
namespace Tests\Unit\helpers;
use Tests\TestCase;
class SlugTest extends TestCase
{
/**
* @return void
*/
public function test_slug_returns_valid_tag_for_cn_characters_when_language_is_set_to_en_US()
{
$tag = str_slug('中文測試', '-', 'en_US');
$this->assertEquals('zhong-wen-ce-shi', $tag);
}
}