mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-03 12:24:46 +00:00
Improved detection of absolute Windows paths.
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@3844 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
7ffdff8f65
commit
f68872f559
2 changed files with 18 additions and 4 deletions
|
|
@ -52,6 +52,10 @@
|
|||
Closes: SF bug #2013873, #2013874
|
||||
Changed: linkchecker
|
||||
|
||||
* Improved filename recognition on Windows systems.
|
||||
Type: bugfix
|
||||
Changed: linkcheck/checker/fileurl.py
|
||||
|
||||
4.9 "Michael Clayton" (released 25.4.2008)
|
||||
|
||||
* Parse Shockwave Flash (SWF) for URLs to check
|
||||
|
|
|
|||
|
|
@ -70,6 +70,15 @@ def get_nt_filename (path):
|
|||
return path
|
||||
|
||||
|
||||
def is_absolute_path (path):
|
||||
"""Check if given path is absolute. On Windows absolute paths start
|
||||
with a drive letter. On all other systems absolute paths start with
|
||||
a slash."""
|
||||
if os.name == 'nt':
|
||||
re.search(r"^[a-zA-Z]:", path)
|
||||
return path.startswith("/")
|
||||
|
||||
|
||||
class FileUrl (urlbase.UrlBase):
|
||||
"""
|
||||
Url link with file scheme.
|
||||
|
|
@ -90,12 +99,13 @@ class FileUrl (urlbase.UrlBase):
|
|||
base_url = self.base_url
|
||||
if not (parent_url or base_ref or base_url.startswith("file:")):
|
||||
base_url = os.path.expanduser(base_url)
|
||||
if not base_url.startswith("/"):
|
||||
if not is_absolute_path(base_url):
|
||||
base_url = os.getcwd()+"/"+base_url
|
||||
base_url = "file://"+base_url
|
||||
base_url = base_url.replace("\\", "/")
|
||||
# transform c:/windows into /c|/windows
|
||||
base_url = re.sub("^file://(/?)([a-zA-Z]):", r"file:///\2|", base_url)
|
||||
if os.name == "nt":
|
||||
base_url = base_url.replace("\\", "/")
|
||||
# transform c:/windows into /c|/windows
|
||||
base_url = re.sub("^file://(/?)([a-zA-Z]):", r"file:///\2|", base_url)
|
||||
# norm base url again after changing
|
||||
if self.base_url != base_url:
|
||||
base_url, is_idn = urlbase.url_norm(base_url)
|
||||
|
|
|
|||
Loading…
Reference in a new issue