mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
moved more logic around
This commit is contained in:
parent
ae5bfe500e
commit
863e2f468f
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user