bzrlib.urlutils
Andrew Bennetts
andrew.bennetts at canonical.com
Fri Mar 26 00:55:50 GMT 2010
Andrew Bennetts wrote:
[...]
> Where in urlparse are alternatives to urlutils.join,
I should elaborate on this one. urlparse.urljoin is pretty similar[1], but
there's at least one crucial difference in behaviour for bzrlib:
>>> from urlparse import urljoin
>>> urljoin('http://example.com/foo', '../../newpath')
'http://example.com/../../newpath'
>>> from bzrlib.urlutils import join
>>> join('http://example.com/foo', '../../newpath')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "bzrlib/urlutils.py", line 168, in join
path = joinpath(path, arg)
File "bzrlib/urlutils.py", line 207, in joinpath
base, args)
bzrlib.errors.InvalidURLJoin: Invalid URL join request: Cannot go above root: '/foo' + ('../../newpath',)
-Andrew.
[1] although the documentation at
<http://docs.python.org/library/urlparse.html#urlparse.urljoin> isn't very
clear that it can take both “absolute” URLs like http://example.com/foo as
well as a “relative” URL like /foo.
More information about the bazaar
mailing list