1
0
Fork 0
mirror of synced 2024-05-29 16:40:06 +12:00

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
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)
if not match:
raise errors.BulkDownloaderException(f'Could not find subreddit name in string {subreddit}')