Skip to content

Commit

Permalink
[RedditBridge] Add detectParameters (#2070)
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidsowa authored Apr 19, 2021
1 parent 13e9a96 commit 4f7ef21
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions bridges/RedditBridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
Expand Down

0 comments on commit 4f7ef21

Please # to comment.