From af343a418215c776e0a49ea5a56a241e8d2ffb37 Mon Sep 17 00:00:00 2001 From: Bravewood Date: Mon, 10 Aug 2015 16:34:54 +0900 Subject: [PATCH] fix: add non alphabet slug --- src/AppBundle/Tests/Utils/SluggerTest.php | 6 ++++++ src/AppBundle/Utils/Slugger.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/AppBundle/Tests/Utils/SluggerTest.php b/src/AppBundle/Tests/Utils/SluggerTest.php index 6f6772487..9384f5feb 100644 --- a/src/AppBundle/Tests/Utils/SluggerTest.php +++ b/src/AppBundle/Tests/Utils/SluggerTest.php @@ -44,6 +44,12 @@ public function getSlugs() array(' lOrEm iPsUm ' , 'lorem-ipsum'), array('!Lorem Ipsum!' , 'lorem-ipsum'), array('lorem-ipsum' , 'lorem-ipsum'), + array('русский язык' , 'русский-язык'), + array(' русский язык ', 'русский-язык'), + array('日本語' , '日本語'), + array(' 日本語 ' , '日本語'), + array(' 日 本 語!' , '日-本-語'), + array('日本語#&' , '日本語'), ); } } diff --git a/src/AppBundle/Utils/Slugger.php b/src/AppBundle/Utils/Slugger.php index 9ffaa9bda..246d5402b 100644 --- a/src/AppBundle/Utils/Slugger.php +++ b/src/AppBundle/Utils/Slugger.php @@ -22,6 +22,6 @@ class Slugger { public function slugify($string) { - return trim(preg_replace('/[^a-z0-9]+/', '-', strtolower(strip_tags($string))), '-'); + return trim(preg_replace('/[\s\!\#\&]+/', '-', mb_strtolower(strip_tags($string))), '-'); } }