Skip to content

Commit

Permalink
Fix for Issue #455
Browse files Browse the repository at this point in the history
  • Loading branch information
darron1217 committed Jan 15, 2018
1 parent a96dec0 commit 3fd7f0a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions Modules/Core/helpers.php
Expand Up @@ -54,3 +54,24 @@ function asgard_editor($fieldName, $labelName, $content)
return view('core::components.textarea-wrapper', compact('fieldName', 'labelName', 'content'));
}
}

if (! function_exists('utf8_slug')) {
function utf8_slug($title, $separator = '-')
{
// Convert all dashes/underscores into separator
$flip = $separator == '-' ? '_' : '-';

$title = preg_replace('!['.preg_quote($flip).']+!u', $separator, $title);

// Replace @ with the word 'at'
$title = str_replace('@', $separator.'at'.$separator, $title);

// Remove all characters that are not the separator, letters, numbers, or whitespace.
$title = preg_replace('![^'.preg_quote($separator).'\pL\pN\s]+!u', '', mb_strtolower($title));

// Replace all separator characters and whitespace by a single separator
$title = preg_replace('!['.preg_quote($separator).'\s]+!u', $separator, $title);

return trim($title, $separator);
}
}
2 changes: 1 addition & 1 deletion Modules/Tag/Traits/TaggableTrait.php
Expand Up @@ -206,6 +206,6 @@ protected function getEntityClassName()
*/
protected function generateTagSlug($name)
{
return str_slug($name);
return utf8_slug($name);
}
}

0 comments on commit 3fd7f0a

Please sign in to comment.