do not apply regex replacements if there is no @ character

This commit is contained in:
n 2024-01-28 17:23:23 +01:00
parent d18aa0ef47
commit 98488c2c17
Signed by: n
GPG key ID: 510227DD6C502CE3

View file

@ -16,11 +16,10 @@ function hook_clickat_render_linklist($data)
'/\ @([\w\d]+)@([\w\d_\-\.]+)/' => ' <a href="https://\2/@\1">&commat;\1</a>', '/\ @([\w\d]+)@([\w\d_\-\.]+)/' => ' <a href="https://\2/@\1">&commat;\1</a>',
'/\ @([\w\d]+)/' => ' <a href="https://twitter.com/\1">&commat;\1</a>' '/\ @([\w\d]+)/' => ' <a href="https://twitter.com/\1">&commat;\1</a>'
); );
foreach ($data['links'] as &$value) { foreach ($data['links'] as &$value)
foreach($patterns as $nic => $link) { if (strpos($value['description'],' @') !== false)
$value['description'] = preg_replace($nic, $link, $value['description']); foreach($patterns as $nic => $link)
} $value['description'] = preg_replace($nic, $link, $value['description']);
}
return $data; return $data;
} }