From f29f2b3cfa6e914e325e2918d7e4ab3696c385c4 Mon Sep 17 00:00:00 2001 From: Zevaryx Date: Fri, 24 Jun 2022 17:17:20 -0600 Subject: [PATCH] Fix regex pattern --- jarvis/cogs/reddit.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jarvis/cogs/reddit.py b/jarvis/cogs/reddit.py index 235ac5c..ed93c54 100644 --- a/jarvis/cogs/reddit.py +++ b/jarvis/cogs/reddit.py @@ -30,7 +30,7 @@ from jarvis.utils.permissions import admin_or_permissions DEFAULT_USER_AGENT = f"python:JARVIS:{const.__version__} (by u/zevaryx)" sub_name = re.compile(r"\A[A-Za-z0-9][A-Za-z0-9_]{2,20}\Z") -image_link = re.compile(r".*preview\.redd\.it\/(.*\..*)\?.*") +image_link = re.compile(r"https?://(?:www)?\.?preview\.redd\.it\/(.*\..*)\?.*") class RedditCog(Extension): @@ -90,7 +90,7 @@ class RedditCog(Extension): if post.spoiler: content += "||" content += f"\n\n[View this post]({url})" - content = "\n".join(image_link.sub(r"https://i.redd.it/\2", x) for x in content.split("\n")) + content = "\n".join(image_link.sub(r"https://i.redd.it/\1", x) for x in content.split("\n")) if not images and not content: self.logger.debug(f"Post {post.id} had neither content nor images?")