furl
furl copied to clipboard
.join() and .path.normalize() incorrectly interpret base paths ending /. or /..
When joining URLs, furl correctly treats a path /a/b/c/d/../
as equivalent to /a/b/c/
, but it incorrectly treats /a/b/c/d/..
as equivalent to /a/b/c
rather than /a/b/c/
(with a trailing slash). This causes further path components to be joined at the wrong level.
>>> furl("http://host/a/b/c/d/../").join("D") # correct
furl('http://host/a/b/c/D')
>>> furl("http://host/a/b/c/d/..").join("D") # expected furl('http://host/a/b/c/D')
furl('http://host/a/b/c/d/D')
A similar problem can be observed with .path.normalize()
. This one also affects paths ending in /.
:
>>> furl("http://host/a/b/c/d/./").path.normalize() # correct
Path('/a/b/c/d/')
>>> furl("http://host/a/b/c/d/../").path.normalize() # correct
Path('/a/b/c/')
>>> furl("http://host/a/b/c/d/.").path.normalize() # expected Path('/a/b/c/d/')
Path('/a/b/c/d')
>>> furl("http://host/a/b/c/d/..").path.normalize() # expected Path('/a/b/c/')
Path('/a/b/c')