diff --git a/app/Lib/Utils.php b/app/Lib/Utils.php index 10c11b6..457dc2e 100644 --- a/app/Lib/Utils.php +++ b/app/Lib/Utils.php @@ -9,11 +9,16 @@ class Utils $text = e($text); // url replace and email replace $text = preg_replace_callback( - '/([^\s@]+@([^\s@.,]+\.)+[^\s@.,]{2,})|(?:http[s]?:\/\/.)?(?:www\.)?[-a-zA-Z0-9@%._\+~#=]{2,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*)/', + '/(?P[^\s@]+@([^\s@.,]+\.)+[^\s@.,]{2,})|(?P@\w*)|(?P(?:http[s]?:\/\/.)?(?:www\.)?[-a-zA-Z0-9@%._\+~#=]{2,256}\.[a-z]{2,6}\b(?:[-a-zA-Z0-9@:%_\+.~#?&\/\/=]*))/', function ($matches) { $match = collect($matches)->first() ?? ''; if (filter_var($match, FILTER_VALIDATE_EMAIL)) { return strlen($match) ? "$match" : $match; + } elseif (isset($matches['user']) and strlen($matches['user'])) { + return sprintf( + '%s', + $matches['user'] + ); } else { $url = $match; if (\strpos($url, 'http') === false and \strpos($url, 'https') === false) {