[RedditBridge] Add detectParameters (#2070)

This commit is contained in:
dawidsowa 2021-04-19 19:17:36 +02:00 committed by GitHub
parent 13e9a96cf3
commit 4f7ef212b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -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() { public function getIcon() {
return 'https://www.redditstatic.com/desktop2x/img/favicon/favicon-96x96.png'; return 'https://www.redditstatic.com/desktop2x/img/favicon/favicon-96x96.png';
} }