From b7e7ff9a626dd5bd51ed291edd2de9075b69ffc8 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 10 Jul 2021 18:51:55 +0200 Subject: unshorturl: Only replace url if we could expand it --- unshorturl/unshorturl.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/unshorturl/unshorturl.php b/unshorturl/unshorturl.php index 6340e9a..e31268a 100644 --- a/unshorturl/unshorturl.php +++ b/unshorturl/unshorturl.php @@ -50,9 +50,11 @@ function unshorturl_prepare_body(&$body) { $num_matches = preg_match_all('/https?:\/\/bit\.ly\/\w+/', $body['html'], $matches); if ($num_matches > 0) { foreach ($matches as $links) { - error_log('unshorturl: Links found: ' . implode(', ', $links)); foreach($links as $l) { - $body['html'] = str_replace($l, unshorturl_get_long_url($l), $body['html']); + $longurl = unshorturl_get_long_url($l); + if ($longurl) { + $body['html'] = str_replace($l, $longurl, $body['html']); + } } } } -- cgit v1.2.3