[COMPONENT][Link] Fix mistake where only the first URL was matched and the match included the preceeding whitespace character

This commit is contained in:
Hugo Sales 2021-10-24 21:30:47 +01:00 committed by Diogo Peralta Cordeiro
parent ebf675ec59
commit 364c14ef2c
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0

View File

@ -42,8 +42,8 @@ class Link extends Component
{
if (Common::config('attachments', 'process_links')) {
$matched_urls = [];
preg_match($this->getURLRegex(), $content, $matched_urls);
$matched_urls = array_unique($matched_urls);
preg_match_all($this->getURLRegex(), $content, $matched_urls);
$matched_urls = array_unique($matched_urls[1]);
foreach ($matched_urls as $match) {
try {
$link_id = Entity\Link::getOrCreate($match)->getId();