Skip to content

Commit

Permalink
fix: Enable tag slug creation from CN characters (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
keriati authored Dec 16, 2022
1 parent 0d9850c commit 9e6321e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
6 changes: 2 additions & 4 deletions app/Http/Controllers/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@

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
{
Expand Down Expand Up @@ -68,7 +66,7 @@ public function store(Request $request): RedirectResponse
]);
}

$slug = str_slug($request->title, '-');
$slug = str_slug($request->title, '-', 'en_US');

$current_user = User::currentUser();

Expand Down Expand Up @@ -140,7 +138,7 @@ public function update(Request $request, int $id): RedirectResponse
]);
}

$slug = str_slug($request->title, '-');
$slug = str_slug($request->title, '-', 'en_US');
// set item type to tag
$request->merge([
'url' => $slug,
Expand Down
18 changes: 18 additions & 0 deletions tests/Unit/helpers/SlugTest.php
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 9e6321e

Please sign in to comment.