- Simplified SLUG() method of the UrlExtension, since it was way too slow

This commit is contained in:
Dave M. 2023-02-01 18:06:23 +00:00
parent 08211282c2
commit 2dc16de7c3
1 changed files with 1 additions and 1 deletions

View File

@ -126,7 +126,7 @@ PATTERN;
# src: https://stackoverflow.com/a/14550919 # src: https://stackoverflow.com/a/14550919
public static function slug(string $text, string $separator = '-') : string public static function slug(string $text, string $separator = '-') : string
{ {
$clean = iconv('UTF-8', 'ASCII//TRANSLIT', $text); $clean = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $text);
$clean = preg_replace("/[^a-zA-Z0-9\/_| -]/", '', $clean); $clean = preg_replace("/[^a-zA-Z0-9\/_| -]/", '', $clean);
return preg_replace("/[\/_| -]+/", $separator, strtolower(trim($clean, '-'))); return preg_replace("/[\/_| -]+/", $separator, strtolower(trim($clean, '-')));