Skip to content

Commit

Permalink
Adding functions to verify subreddit and user
Browse files Browse the repository at this point in the history
  • Loading branch information
jpontoire committed Oct 9, 2024
1 parent 06c8ba4 commit fccc5eb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
18 changes: 18 additions & 0 deletions ural/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,24 @@ def is_reddit_url(url):
return bool(re.match(REDDIT_URL_RE, url))


def is_subreddit_url(url):
if not is_reddit_url(url):
return False

return (
'/r/' in url
)


def is_reddit_user_url(url):
if not is_reddit_url(url):
return False

return (
'/user/' in url
)


def is_reddit_post_url(url):
if not is_reddit_url(url):
return False
Expand Down
6 changes: 4 additions & 2 deletions ural/reddit.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ from typing import Optional
from ural.types import AnyUrlTarget

def is_reddit_url(url: str) -> bool : ...
def is_subreddit_url(url: str) -> bool : ...
def is_reddit_user_url(url: str) -> bool : ...
def is_reddit_post_url(url: str) -> bool : ...
def convert_reddit_url_to_old_url(url: str) -> bool : ...
def convert_old_reddit_url_to_new_url(url: str) -> bool : ...
def convert_reddit_url_to_old_url(url: str) -> str : ...
def convert_old_reddit_url_to_new_url(url: str) -> str : ...

0 comments on commit fccc5eb

Please sign in to comment.