-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Describe the bug:
When generating documentation the source badge creates non-compliant URLs. Specifically, when combining value provided by -src-base-url
with the path, it seems to use the OS specific path separator. This results in URLs that look like:
https://src-base-url/path/to/repo\file.py
Expected behaviour:
I would expect this to function correctly on any operating system. Rather than the incorrect URL above, the source badge should use the correct path separator:
https://src-base-url/path/to/repo/file.py
Steps to reproduce the issue:
Run lazydocs on Windows with virtually any configuration. I run it specifying an output path and base url for the source.
Technical details:
- Host Machine OS (Windows/Linux/Mac): Windows
- Browser (Chrome/Firefox/Safari): Firefox
Possible Fix:
In generation.py
rather than os.path.join
I would suggest using urljoin
from urllib
. Example:
from urllib.parse import urljoin
# ... generation.py contents...
if append_base and self.src_base_url:
relative_path = urljoin(self.src_base_url, relative_path)
# ... everything else...
Additional context:
https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin