aboutsummaryrefslogtreecommitdiffstats
path: root/unshorturl/unshorturl.php
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2021-07-10 14:51:12 +0200
committerHarald Eilertsen <haraldei@anduin.net>2021-07-10 14:51:12 +0200
commit3613ba714878f8503d590bb24423572d1bc54ee7 (patch)
tree1c4dc180513732e75782bbb9ee629eb7044453dc /unshorturl/unshorturl.php
downloadvolse-hz-addons-3613ba714878f8503d590bb24423572d1bc54ee7.tar.gz
volse-hz-addons-3613ba714878f8503d590bb24423572d1bc54ee7.tar.bz2
volse-hz-addons-3613ba714878f8503d590bb24423572d1bc54ee7.zip
Initial commit, the start of an unshorturl addon.
Diffstat (limited to 'unshorturl/unshorturl.php')
-rw-r--r--unshorturl/unshorturl.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/unshorturl/unshorturl.php b/unshorturl/unshorturl.php
new file mode 100644
index 0000000..626891f
--- /dev/null
+++ b/unshorturl/unshorturl.php
@@ -0,0 +1,31 @@
+<?php
+
+/**
+ * Name: UnshortURL
+ * Description: Expand shortened URLs into their proper URLs
+ * Version: 0.1.0
+ * Author: Harald Eilertsen <https://hub.volse.no/channel/harald>
+ * Maintainer: Harald Eilertsen <https://hub.volse.no/channel/harald>
+ *
+ * SPDX-FileCopyrightText: 2021 Harald Eilertsen <haraldei@anduin.net>
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+use Zotlabs\Lib\Apps;
+use Zotlabs\Extend\Hooks;
+
+function unshorturl_install() {
+ Hook::register('perpare_body', 'addon/unshorturl/unshorturl.php', 'unshorturl_prepare_body', 1);
+}
+
+function unshorturl_uninstall() {
+ Hook::deregister('prepare_body', 'addon/unshorturl/unshorturl.php', 'unshorturl_prepare_body');
+}
+
+function unshorturl_prepare_body(&$body) {
+ if (!local_channel() || !Apps::addon_app_installed(local_channel(), 'unshorturl')) {
+ return;
+ }
+
+ preg_replace('/https?:\/\/bit.ly\/[^\s]+/g', '[hidden bitly link]');
+}