From 21ae8bab2fb4c9e1b78e82988a756ed9347be9c2 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Mon, 13 Sep 2021 21:36:49 +0200 Subject: Remove duplicate matches. Since we do a str_replace, we don't need to look up the same URL more than once for each post. --- unshorturl/unshorturl.php | 1 + 1 file changed, 1 insertion(+) diff --git a/unshorturl/unshorturl.php b/unshorturl/unshorturl.php index cbe3208..cd09e13 100644 --- a/unshorturl/unshorturl.php +++ b/unshorturl/unshorturl.php @@ -49,6 +49,7 @@ function unshorturl_prepare_body(&$body) { $matches = []; $num_matches = preg_match_all('/https?:\/\/(bit\.ly|dlvr\.it|t\.co)\/\w+/', $body['html'], $matches); if ($num_matches > 0) { + $matches = array_unique($matches); foreach ($matches as $links) { foreach($links as $l) { $longurl = unshorturl_get_long_url($l); -- cgit v1.2.3