diff --git a/files/helpers/actions.py b/files/helpers/actions.py index a81cea5b77..a1154839a8 100644 --- a/files/helpers/actions.py +++ b/files/helpers/actions.py @@ -168,7 +168,7 @@ def execute_snappy(post, v): body += "\n\n" if post.url and not post.url.startswith('/') and not post.url.startswith(f'{SITE_FULL}/') and not post.url.startswith(SITE_FULL_IMAGES): - if post.url.startswith('https://old.reddit.com/r/'): + if reddit_post_permalink_regex.fullmatch(post.url): rev = post.url.replace('https://old.reddit.com/', '') rev = f"* [undelete.pullpush.io](https://undelete.pullpush.io/{rev})\n\n" elif post.url.startswith("https://old.reddit.com/user/"): @@ -195,7 +195,7 @@ def execute_snappy(post, v): if "Snapshots:\n\n" not in body: body += "Snapshots:\n\n" if f'**[{title}]({href})**:\n\n' not in body: addition = f'**[{title}]({href})**:\n\n' - if href.startswith('https://old.reddit.com/r/'): + if reddit_post_permalink_regex.fullmatch(href): rev = href.replace('https://old.reddit.com/', '') addition += f'* [undelete.pullpush.io](https://undelete.pullpush.io/{rev})\n\n' elif href.startswith('https://old.reddit.com/user/'): diff --git a/files/helpers/regex.py b/files/helpers/regex.py index e1f1e42290..9bae505562 100644 --- a/files/helpers/regex.py +++ b/files/helpers/regex.py @@ -248,6 +248,8 @@ reddit_to_vreddit_regex = re.compile('(^|>|")https:\/\/old.reddit.com\/([ru])\/' #post search subreddit_name_regex = re.compile('\w{2,25}', flags=re.A) +#undelete.pullpush.io +reddit_post_permalink_regex = re.compile('https:\/\/old.reddit.com\/r\/\w{2,25}\/comments\/.*', flags=re.A) ###YOUTUBE