mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-14 03:11:03 +00:00
commit
314ec085a3
4 changed files with 39 additions and 5 deletions
|
|
@ -363,11 +363,13 @@ class UrlBase:
|
|||
|
||||
def set_cache_url(self):
|
||||
"""Set the URL to be used for caching."""
|
||||
# remove anchor from cached target url since we assume
|
||||
# URLs with different anchors to have the same content
|
||||
self.cache_url = urlutil.urlunsplit(self.urlparts[:4] + [''])
|
||||
if self.cache_url is not None:
|
||||
assert isinstance(self.cache_url, str), repr(self.cache_url)
|
||||
if "AnchorCheck" in self.aggregate.config["enabledplugins"]:
|
||||
self.cache_url = self.url
|
||||
else:
|
||||
# remove anchor from cached target url since we assume
|
||||
# URLs with different anchors to have the same content
|
||||
self.cache_url = urlutil.urlunsplit(self.urlparts[:4] + [''])
|
||||
log.debug(LOG_CHECK, "cache_url '%s'", self.cache_url)
|
||||
|
||||
def check_syntax(self):
|
||||
"""
|
||||
|
|
|
|||
4
tests/checker/data/http_anchor.html
Normal file
4
tests/checker/data/http_anchor.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<p id="good">
|
||||
<a href="http_anchor.html">a</a>
|
||||
<a href="http_anchor.html#good">a_good</a>
|
||||
<a href="http_anchor.html#bad">a_bad</a>
|
||||
17
tests/checker/data/http_anchor.html.result
Normal file
17
tests/checker/data/http_anchor.html.result
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
url http://localhost:%(port)d/%(datadir)s/http_anchor.html
|
||||
cache key http://localhost:%(port)d/%(datadir)s/http_anchor.html
|
||||
real url http://localhost:%(port)d/%(datadir)s/http_anchor.html
|
||||
valid
|
||||
|
||||
url http_anchor.html#bad
|
||||
cache key http://localhost:%(port)d/%(datadir)s/http_anchor.html#bad
|
||||
real url http://localhost:%(port)d/%(datadir)s/http_anchor.html#bad
|
||||
name a_bad
|
||||
warning Anchor `bad' not found. Available anchors: `good'.
|
||||
valid
|
||||
|
||||
url http_anchor.html#good
|
||||
cache key http://localhost:%(port)d/%(datadir)s/http_anchor.html#good
|
||||
real url http://localhost:%(port)d/%(datadir)s/http_anchor.html#good
|
||||
name a_good
|
||||
valid
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
Test html anchor parsing and checking.
|
||||
"""
|
||||
from . import LinkCheckTest
|
||||
from .httpserver import HttpServerTest
|
||||
|
||||
|
||||
class TestAnchor(LinkCheckTest):
|
||||
|
|
@ -38,3 +39,13 @@ class TestAnchor(LinkCheckTest):
|
|||
"valid",
|
||||
]
|
||||
self.direct(urlanchor, resultlines, confargs=confargs)
|
||||
|
||||
|
||||
class TestHttpAnchor(HttpServerTest):
|
||||
"""
|
||||
Test checking of HTML pages containing links to anchors served over http.
|
||||
"""
|
||||
|
||||
def test_anchor_html(self):
|
||||
confargs = dict(enabledplugins=["AnchorCheck"], recursionlevel=1)
|
||||
self.file_test("http_anchor.html", confargs=confargs)
|
||||
|
|
|
|||
Loading…
Reference in a new issue