diff --git a/daemon_post_search.py b/daemon_post_search.py index 0d312c286..f98cc8c0f 100644 --- a/daemon_post_search.py +++ b/daemon_post_search.py @@ -354,9 +354,7 @@ def receive_search_query(self, calling_domain: str, cookie: str, if search_str.endswith(';remote'): search_str = search_str.replace(';remote', '') remote_only = True - if search_str.endswith(':') or \ - search_str.endswith(';') or \ - search_str.endswith('.'): + if string_ends_with(search_str, (':', ';', '.')): actor_str = \ get_instance_url(calling_domain, http_prefix, domain_full, onion_domain, diff --git a/theme.py b/theme.py index aba47bb3b..5ec05241a 100644 --- a/theme.py +++ b/theme.py @@ -8,6 +8,7 @@ __status__ = "Production" __module_group__ = "Web Interface" import os +from utils import string_ends_with from utils import is_account_dir from utils import load_json from utils import save_json @@ -653,10 +654,7 @@ def _set_theme_fonts(base_dir: str, theme_name: str) -> None: return for _, _, files in os.walk(theme_fonts_dir): for filename in files: - if filename.endswith('.woff2') or \ - filename.endswith('.woff') or \ - filename.endswith('.ttf') or \ - filename.endswith('.otf'): + if string_ends_with(filename, ('.woff2', '.woff', '.ttf', '.otf')): dest_filename = fonts_dir + '/' + filename if os.path.isfile(dest_filename): # font already exists in the destination location diff --git a/webapp_media.py b/webapp_media.py index 355ebc23d..d29a22e0b 100644 --- a/webapp_media.py +++ b/webapp_media.py @@ -8,6 +8,7 @@ __status__ = "Production" __module_group__ = "Timeline" import os +from utils import string_ends_with from utils import valid_url_prefix @@ -250,12 +251,10 @@ def _add_embedded_video_from_sites(content: str, url = url.split('"')[0] if not url: continue - if url.endswith('/trending') or \ - url.endswith('/home') or \ - url.endswith('/overview') or \ - url.endswith('/recently-added') or \ - url.endswith('/local') or \ - url.endswith('/about'): + possible_endings = ( + '/trending', '/home', '/overview', + '/recently-added', '/local', '/about') + if string_ends_with(url, possible_endings): # ignore various peertube endpoints continue if '/c/' in url or '/m/' in url: