Simplify regex string slightly

This commit is contained in:
Serene-Arc
2021-04-23 20:48:00 +10:00
parent 386d5ea41c
commit 214c883a10

View File

@@ -207,7 +207,7 @@ class RedditDownloader:
@staticmethod @staticmethod
def _sanitise_subreddit_name(subreddit: str) -> str: def _sanitise_subreddit_name(subreddit: str) -> str:
pattern = re.compile(r'^(?:https://www\.reddit\.com/)?(?:r/)?(.*?)(?:/)?$') pattern = re.compile(r'^(?:https://www\.reddit\.com/)?(?:r/)?(.*?)/?$')
match = re.match(pattern, subreddit) match = re.match(pattern, subreddit)
if not match: if not match:
raise errors.BulkDownloaderException(f'Could not find subreddit name in string {subreddit}') raise errors.BulkDownloaderException(f'Could not find subreddit name in string {subreddit}')