diff --git a/add_webmention.py b/add_webmention.py index 1105640..0175327 100644 --- a/add_webmention.py +++ b/add_webmention.py @@ -21,7 +21,7 @@ CACHE_TIME = datetime.timedelta(seconds=15) def add_wm(url=None): """Proxies HTTP requests and adds Link header to our webmention endpoint.""" url = urllib.parse.unquote(url) - if not url.startswith('http://') and not url.startswith('https://'): + if not util.is_web(url): error('URL must start with http:// or https://') try: diff --git a/follow.py b/follow.py index ce189f7..44b200f 100644 --- a/follow.py +++ b/follow.py @@ -36,7 +36,7 @@ def remote_follow(): if len(split) == 2: addr_domain = split[1] resource = f'acct:{addr}' - elif addr.startswith('http://') or addr.startswith('https://'): + elif util.is_web(addr): addr_domain = util.domain_from_link(addr, minimize=False) resource = addr else: diff --git a/redirect.py b/redirect.py index c4dffe5..9c19ef7 100644 --- a/redirect.py +++ b/redirect.py @@ -43,7 +43,7 @@ def redir(to): # if that happened to this URL, expand it back to two /s. to = re.sub(r'^(https?:/)([^/])', r'\1/\2', to) - if not to.startswith('http://') and not to.startswith('https://'): + if not util.is_web(to): error(f'Expected fully qualified URL; got {to}') # check that we've seen this domain before so we're not an open redirect diff --git a/webfinger.py b/webfinger.py index 3564823..fb0b39a 100644 --- a/webfinger.py +++ b/webfinger.py @@ -186,7 +186,7 @@ class Webfinger(Actor): domain = urllib.parse.urlparse(resource).netloc or resource url = None - if resource.startswith('http://') or resource.startswith('https://'): + if util.is_web(resource): url = resource return super().template_vars(domain=domain, url=url)