From 4f7ef212b7ab10690d6c483273354a995179f98b Mon Sep 17 00:00:00 2001 From: dawidsowa Date: Mon, 19 Apr 2021 19:17:36 +0200 Subject: [PATCH] [RedditBridge] Add detectParameters (#2070) --- bridges/RedditBridge.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/bridges/RedditBridge.php b/bridges/RedditBridge.php index b83871a96a1..82988eba0f1 100644 --- a/bridges/RedditBridge.php +++ b/bridges/RedditBridge.php @@ -48,6 +48,26 @@ class RedditBridge extends BridgeAbstract { ) ); + public function detectParameters($url) { + $parsed_url = parse_url($url); + + if ($parsed_url['host'] != 'www.reddit.com' && $parsed_url['host'] != 'old.reddit.com') return null; + + $path = explode('/', $parsed_url['path']); + + if ($path[1] == 'r') { + return array( + 'r' => $path[2] + ); + } elseif ($path[1] == 'user') { + return array( + 'u' => $path[2] + ); + } else { + return null; + } + } + public function getIcon() { return 'https://www.redditstatic.com/desktop2x/img/favicon/favicon-96x96.png'; }