Skip to content

Commit

Permalink
Link checker should check all absolute URLs to self
Browse files Browse the repository at this point in the history
Fixes issue #1991.
  • Loading branch information
da2x committed Sep 1, 2015
1 parent 79833b8 commit 4e0be1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -27,6 +27,7 @@ Features
Bugfixes
--------

* Link checker should check all absolute URLs to self (Issue #1991)
* Check ``img|source[@srcset]`` as part of ``check -l`` (Issue #1989)
* Clean up translations for third party components
* ``pagekind["main_index"]`` set on the main indexes to differentiate
Expand Down
7 changes: 5 additions & 2 deletions nikola/plugins/command/check.py
Expand Up @@ -217,6 +217,11 @@ def analyze(self, fname, find_sources=False, check_remote=False):
if target == "#":
continue
target, _ = urldefrag(target)

# absolute URL to root-relative
if target.startswith(base_url.geturl()):
target = target.replace(base_url.geturl(), '/')

parsed = urlparse(target)

# Warn about links from https to http (mixed-security)
Expand All @@ -229,8 +234,6 @@ def analyze(self, fname, find_sources=False, check_remote=False):
((parsed.scheme or target.startswith('//')) and url_type in ('rel_path', 'full_path')):
if not check_remote or parsed.scheme not in ["http", "https"]:
continue
if parsed.netloc == base_url.netloc: # absolute URL to self.site
continue
if target in self.checked_remote_targets: # already checked this exact target
if self.checked_remote_targets[target] in [301, 307]:
self.logger.warn("Remote link PERMANENTLY redirected in {0}: {1} [Error {2}]".format(filename, target, self.checked_remote_targets[target]))
Expand Down

0 comments on commit 4e0be1b

Please sign in to comment.