aboutsummaryrefslogtreecommitdiffstats
path: root/unshorturl/unshorturl.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-07-10 17:35:01 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-07-10 17:35:01 +0200
commit28ea8829a07db685d4d016e1bdd3f320b73e9add (patch)
tree438998e5f4e2f7f75f771228d8157704e2df7ceb /unshorturl/unshorturl.php
parent9f2ec2f89ee9cbed6e5d74b1f7b5132cc8b44ea7 (diff)
downloadvolse-hz-addons-28ea8829a07db685d4d016e1bdd3f320b73e9add.tar.gz
volse-hz-addons-28ea8829a07db685d4d016e1bdd3f320b73e9add.tar.bz2
volse-hz-addons-28ea8829a07db685d4d016e1bdd3f320b73e9add.zip
unshorturl: A possibly better way to replace the links.
Diffstat (limited to 'unshorturl/unshorturl.php')
-rw-r--r--unshorturl/unshorturl.php11
1 files changed, 10 insertions, 1 deletions
diff --git a/unshorturl/unshorturl.php b/unshorturl/unshorturl.php
index bf79fe3..70d7cf6 100644
--- a/unshorturl/unshorturl.php
+++ b/unshorturl/unshorturl.php
@@ -27,5 +27,14 @@ function unshorturl_prepare_body(&$body) {
return;
}
- preg_replace('/https?:\/\/bit.ly\/[^\s]+/', '[hidden bitly link]', $body['html']);
+ $matches = [];
+ $num_matches = preg_match_all('/https?:\/\/bit\.ly\/\w+/', $body['html'], $links);
+ if ($num_matches > 0) {
+ foreach ($matches as $links) {
+ error_log('unshorturl: Links found: ' . implode(', ', $links));
+ foreach($links as $l) {
+ str_replace($l, '[filtered bit.ly url]', $body['html']);
+ }
+ }
+ }
}