mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-29 00:38:11 -05:00
Convert or-ed startswith()s to tuples elsewhere
This commit is contained in:
@@ -96,7 +96,7 @@ def fetch_url(url, referer = None, retries = 1, dimension = False):
|
||||
nothing = None if dimension else (None, None)
|
||||
url = clean_url(url)
|
||||
#just basic urls
|
||||
if not (url.startswith('http://') or url.startswith('https://')):
|
||||
if not url.startswith(('http://', 'https://')):
|
||||
return nothing
|
||||
while True:
|
||||
try:
|
||||
|
||||
@@ -378,7 +378,7 @@ def add_sr(path, sr_path = True, nocname=False, force_hostname = False, retain_e
|
||||
c.cname, c.render_style, c.site.name
|
||||
"""
|
||||
# don't do anything if it is just an anchor
|
||||
if path.startswith('#') or path.startswith('javascript:'):
|
||||
if path.startswith(('#', 'javascript:')):
|
||||
return path
|
||||
|
||||
u = UrlParser(path)
|
||||
|
||||
@@ -251,7 +251,7 @@ def path_component(s):
|
||||
def get_title(url):
|
||||
"""Fetches the contents of url and extracts (and utf-8 encodes)
|
||||
the contents of <title>"""
|
||||
if not url or not (url.startswith('http://') or url.startswith('https://')):
|
||||
if not url or not url.startswith(('http://', 'https://')):
|
||||
return None
|
||||
|
||||
try:
|
||||
|
||||
@@ -1808,10 +1808,7 @@ class VDestination(Validator):
|
||||
dest = request.referer or self.default or "/"
|
||||
|
||||
ld = dest.lower()
|
||||
if (ld.startswith("/") or
|
||||
ld.startswith("http://") or
|
||||
ld.startswith("https://")):
|
||||
|
||||
if ld.startswith(('/', 'http://', 'http://')):
|
||||
u = UrlParser(dest)
|
||||
|
||||
if u.is_reddit_url(c.site):
|
||||
|
||||
Reference in New Issue
Block a user