Skip to content
Permalink
Browse files

Link checker should check all absolute URLs to self

Fixes issue #1991.
  • Loading branch information
da2x committed Sep 1, 2015
1 parent 79833b8 commit 4e0be1be73a78792522bac9f019bf5f204b186a9
Showing with 6 additions and 2 deletions.
  1. +1 −0 CHANGES.txt
  2. +5 −2 nikola/plugins/command/check.py
@@ -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
@@ -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)
@@ -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]))

0 comments on commit 4e0be1b

Please sign in to comment.
You can’t perform that action at this time.