Rev 2159: Small bugfix to urlutils.join: join('anything', 'http://bar/a/') should not strip the trailing slash. in sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/

Andrew Bennetts andrew.bennetts at canonical.com
Tue Mar 6 08:07:18 GMT 2007


At sftp://bazaar.launchpad.net/%7Ebzr/bzr/hpss/

------------------------------------------------------------
revno: 2159
revision-id: andrew.bennetts at canonical.com-20070306080144-frjogke5hvc7a2t7
parent: andrew.bennetts at canonical.com-20070306071340-1nsftdleyx0ye73k
committer: Andrew Bennetts <andrew.bennetts at canonical.com>
branch nick: hpss
timestamp: Tue 2007-03-06 19:01:44 +1100
message:
  Small bugfix to urlutils.join: join('anything', 'http://bar/a/') should not strip the trailing slash.
modified:
  bzrlib/tests/test_urlutils.py  test_urlutils.py-20060502192900-46b1f9579987cf9c
  bzrlib/urlutils.py             urlutils.py-20060502195429-e8a161ecf8fac004
=== modified file 'bzrlib/tests/test_urlutils.py'
--- a/bzrlib/tests/test_urlutils.py	2007-03-01 05:08:32 +0000
+++ b/bzrlib/tests/test_urlutils.py	2007-03-06 08:01:44 +0000
@@ -212,6 +212,9 @@
         test('http://bar', 'http://foo', 'http://bar')
         test('sftp://bzr/foo', 'http://foo', 'bar', 'sftp://bzr/foo')
         test('file:///bar', 'foo', 'file:///bar')
+        test('http://bar/', 'http://foo', 'http://bar/')
+        test('http://bar/a', 'http://foo', 'http://bar/a')
+        test('http://bar/a/', 'http://foo', 'http://bar/a/')
 
         # From a base path
         test('file:///foo', 'file:///', 'foo')

=== modified file 'bzrlib/urlutils.py'
--- a/bzrlib/urlutils.py	2007-03-01 05:08:32 +0000
+++ b/bzrlib/urlutils.py	2007-03-06 08:01:44 +0000
@@ -148,8 +148,8 @@
             # XXX: duplicates mess from earlier in this function.  This URL
             # manipulation code needs some cleaning up.
             if scheme is not None and len(path) >= 1:
-                host = path[:2]
-                path = path[2:]
+                host = path[:1]
+                path = path[1:]
             else:
                 host = []
         else:
@@ -157,7 +157,9 @@
             path = joinpath(path, arg)
             path = path.split('/')
     if host:
-        if path and path[0] == '':
+        # Remove the leading slash from the path, so long as it isn't also the
+        # trailing slash, which we want to keep if present.
+        if path and path[0] == '' and len(path) > 1:
             del path[0]
         path = host + path
 




More information about the bazaar-commits mailing list