aboutsummaryrefslogtreecommitdiffstats
path: root/unshorturl/unshorturl.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-09-13 21:36:49 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-09-13 21:36:49 +0200
commit21ae8bab2fb4c9e1b78e82988a756ed9347be9c2 (patch)
tree447e3a1aded0dbd487219df06d7161c6e27e265e /unshorturl/unshorturl.php
parent241b9e45184d31d96bb040da807df18f6a5ab4d8 (diff)
downloadvolse-hz-addons-21ae8bab2fb4c9e1b78e82988a756ed9347be9c2.tar.gz
volse-hz-addons-21ae8bab2fb4c9e1b78e82988a756ed9347be9c2.tar.bz2
volse-hz-addons-21ae8bab2fb4c9e1b78e82988a756ed9347be9c2.zip
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.
Diffstat (limited to 'unshorturl/unshorturl.php')
-rw-r--r--unshorturl/unshorturl.php1
1 files changed, 1 insertions, 0 deletions
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);