mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-04-07 08:10:57 +00:00
Fix internal pattern for file URLs (regression from commit 90e0f4e)
This commit is contained in:
parent
6090e1a66c
commit
0d8a583e39
4 changed files with 33 additions and 8 deletions
|
|
@ -266,6 +266,12 @@ class FileUrl (urlbase.UrlBase):
|
|||
@return non-empty regex pattern or None
|
||||
@rtype String or None
|
||||
"""
|
||||
if not self.url:
|
||||
url = self.url
|
||||
if not url:
|
||||
return None
|
||||
return re.escape(self.url)
|
||||
if url.startswith('file://'):
|
||||
i = url.rindex('/')
|
||||
if i > 6:
|
||||
# remove last filename to make directory internal
|
||||
url = url[:i+1]
|
||||
return re.escape(url)
|
||||
|
|
|
|||
3
tests/checker/data/a b/bl.html
Normal file
3
tests/checker/data/a b/bl.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<a href="bl.html#bl">Broken link</a>
|
||||
<a name="BL"><em>Broken link target</em>
|
||||
<a href="el.html">External link</a>
|
||||
2
tests/checker/data/a b/el.html
Normal file
2
tests/checker/data/a b/el.html
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
<a href="#bl">Broken link</a>
|
||||
<a name="BL"><em>Broken link target</em>
|
||||
|
|
@ -131,17 +131,31 @@ class TestFile (LinkCheckTest):
|
|||
self.direct(url, resultlines)
|
||||
|
||||
def test_good_dir_space (self):
|
||||
url = u"file://%(curdir)s/%(datadir)s/a b/" % self.get_attrs()
|
||||
url = u"file://%(curdir)s/%(datadir)s/a b/bl.html" % self.get_attrs()
|
||||
nurl = self.norm(url)
|
||||
url2 = u"file://%(curdir)s/%(datadir)s/a b/el.html" % self.get_attrs()
|
||||
nurl2 = self.norm(url2)
|
||||
resultlines = [
|
||||
u"url %s" % url,
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % nurl,
|
||||
u"valid",
|
||||
u"url t.txt",
|
||||
u"cache key %st.txt" % nurl,
|
||||
u"real url %st.txt" % nurl,
|
||||
u"name t.txt",
|
||||
u"url bl.html#bl",
|
||||
u"cache key %s" % nurl,
|
||||
u"real url %s" % nurl,
|
||||
u"name Broken link",
|
||||
u"warning Anchor `bl' not found. Available anchors: `BL'.",
|
||||
u"valid",
|
||||
u"url el.html",
|
||||
u"cache key %s" % nurl2,
|
||||
u"real url %s" % nurl2,
|
||||
u"name External link",
|
||||
u"valid",
|
||||
u"url #bl",
|
||||
u"cache key %s" % nurl2,
|
||||
u"real url %s" % nurl2,
|
||||
u"name Broken link",
|
||||
u"warning Anchor `bl' not found. Available anchors: `BL'.",
|
||||
u"valid",
|
||||
]
|
||||
self.direct(url, resultlines, recursionlevel=1)
|
||||
self.direct(url, resultlines, recursionlevel=2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue