chore: deliminate regex with forward slash

This commit is contained in:
Timothy Quilling 2023-06-30 00:21:17 -04:00
parent 4751d96a1d
commit b04664f9d5

View file

@ -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<server>.*)/@(?P<username>.*)", url
r"https://(?P<server>[^/]+)/@(?P<username>[^/]+)", 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<server>.*)/@(?P<username>.*)/(?P<toot_id>.*)", url
r"https://(?P<server>[^/]+)/@(?P<username>[^/]+)/(?P<toot_id>[^/]+)", 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<server>.*)/objects/(?P<toot_id>.*)", url)
match = re.match(r"https://(?P<server>[^/]+)/objects/(?P<toot_id>[^/]+)", 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<toot_id>.*)", url)
match = re.match(r"/notice/(?P<toot_id>[^/]+)", 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<server>.*)/users/(?P<username>.*)", url)
match = re.match(r"https://(?P<server>[^/]+)/users/(?P<username>[^/]+)", 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<server>.*)/p/(?P<username>.*)/(?P<toot_id>.*)", url
r"https://(?P<server>[^/]+)/p/(?P<username>[^/]+)/(?P<toot_id>[^/]+)", 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<server>.*)/(?P<username>.*)", url)
match = re.match(r"https://(?P<server>[^/]+)/(?P<username>[^/]+)", url)
if match is not None:
return (match.group("server"), match.group("username"))
return None