mirror of
https://github.com/Kozea/WeasyPrint.git
synced 2024-10-04 07:57:52 +03:00
Fix base_url set to a directory name.
With base_url='/a/b', a relative URL 'c' was resolved to '/a/c'. Now it is resolved to '/a/b/c' if /a/b is a directory, '/a/c' otherwise. This is most likely the expected behavior.
This commit is contained in:
parent
3b769e05c4
commit
eab2646dcc
1
CHANGES
1
CHANGES
@ -13,6 +13,7 @@ Not released yet.
|
||||
|
||||
- Handling of filenames and URLs on Windows
|
||||
- Unicode filenames with older version of py2cairo
|
||||
- ``base_url`` now behaves as expected when set to a directory name.
|
||||
- Make some tests more robust
|
||||
|
||||
|
||||
|
@ -69,6 +69,10 @@ def iri_to_uri(url):
|
||||
def path2url(path):
|
||||
"""Return file URL of `path`"""
|
||||
path = os.path.abspath(path)
|
||||
if os.path.isdir(path):
|
||||
# Make sure directory names have a trailing slash.
|
||||
# Otherwise relative URIs are resolved from the parent directory.
|
||||
path += os.path.sep
|
||||
if isinstance(path, unicode):
|
||||
path = path.encode(FILESYSTEM_ENCODING)
|
||||
path = pathname2url(path)
|
||||
|
Loading…
Reference in New Issue
Block a user