moved more logic around

This commit is contained in:
Alex Gaynor 2016-02-13 08:55:55 -05:00
parent ae5bfe500e
commit 863e2f468f

View File

@ -137,8 +137,20 @@ class CheckExternalLinksBuilder(Builder):
if self.app.config.linkcheck_timeout:
kwargs['timeout'] = self.app.config.linkcheck_timeout
def check_uri():
# split off anchor
if '#' in uri:
req_url, hash = uri.split('#', 1)
else:
req_url = uri
hash = None
# handle non-ASCII URIs
try:
req_url.encode('ascii')
except UnicodeError:
req_url = encode_uri(req_url)
try:
if hash and self.app.config.linkcheck_anchors:
# Read the whole document and see if #hash exists
@ -203,19 +215,6 @@ class CheckExternalLinksBuilder(Builder):
if rex.match(uri):
return 'ignored', '', 0
# split off anchor
if '#' in uri:
req_url, hash = uri.split('#', 1)
else:
req_url = uri
hash = None
# handle non-ASCII URIs
try:
req_url.encode('ascii')
except UnicodeError:
req_url = encode_uri(req_url)
# need to actually check the URI
for _ in range(self.app.config.linkcheck_retries):
status, info, code = check_uri()