diff --git a/find_posts.py b/find_posts.py index dffe86f..fbf4c93 100644 --- a/find_posts.py +++ b/find_posts.py @@ -510,7 +510,7 @@ def parse_url(url, parsed_urls): def parse_mastodon_profile_url(url): """parse a Mastodon Profile URL and return the server and username""" match = re.match( - r"https://(?P.*)/@(?P.*)", url + r"https://(?P[^/]+)/@(?P[^/]+)", url ) if match is not None: return (match.group("server"), match.group("username")) @@ -519,7 +519,7 @@ def parse_mastodon_profile_url(url): def parse_mastodon_url(url): """parse a Mastodon URL and return the server and ID""" match = re.match( - r"https://(?P.*)/@(?P.*)/(?P.*)", url + r"https://(?P[^/]+)/@(?P[^/]+)/(?P[^/]+)", url ) if match is not None: return (match.group("server"), match.group("toot_id")) @@ -528,14 +528,14 @@ def parse_mastodon_url(url): def parse_pleroma_url(url): """parse a Pleroma URL and return the server and ID""" - match = re.match(r"https://(?P.*)/objects/(?P.*)", url) + match = re.match(r"https://(?P[^/]+)/objects/(?P[^/]+)", url) if match is not None: server = match.group("server") url = get_redirect_url(url) if url is None: return None - match = re.match(r"/notice/(?P.*)", url) + match = re.match(r"/notice/(?P[^/]+)", url) if match is not None: return (server, match.group("toot_id")) return None @@ -543,7 +543,7 @@ def parse_pleroma_url(url): def parse_pleroma_profile_url(url): """parse a Pleroma Profile URL and return the server and username""" - match = re.match(r"https://(?P.*)/users/(?P.*)", url) + match = re.match(r"https://(?P[^/]+)/users/(?P[^/]+)", url) if match is not None: return (match.group("server"), match.group("username")) return None @@ -551,7 +551,7 @@ def parse_pleroma_profile_url(url): def parse_pixelfed_url(url): """parse a Pixelfed URL and return the server and ID""" match = re.match( - r"https://(?P.*)/p/(?P.*)/(?P.*)", url + r"https://(?P[^/]+)/p/(?P[^/]+)/(?P[^/]+)", url ) if match is not None: return (match.group("server"), match.group("toot_id")) @@ -559,7 +559,7 @@ def parse_pixelfed_url(url): def parse_pixelfed_profile_url(url): """parse a Pixelfed Profile URL and return the server and username""" - match = re.match(r"https://(?P.*)/(?P.*)", url) + match = re.match(r"https://(?P[^/]+)/(?P[^/]+)", url) if match is not None: return (match.group("server"), match.group("username")) return None