Revision 173f8f52

b/snf-common/synnefo/lib/__init__.py
56 56
    'http://www.test.org/a/b/c/d'
57 57
    >>> join_urls("http://www.test.org/a/b/", "/c/d")
58 58
    'http://www.test.org/a/b/c/d'
59

  
59
    >>> join_urls("/path1", "/path")
60
    '/path1/path'
61
    >>> join_urls("path1", "/path")
62
    'path1/path'
63
    >>> join_urls("path1/")
64
    'path1/'
65
    >>> join_urls("path1/", "path2", "path3")
66
    'path1/path2/path3'
60 67
    """
61
    return "/".join([a.lstrip("/").rstrip("/") for a in args[:-1]]) + \
62
            "/" + args[-1].lstrip("/")
68
    if len(args) == 1:
69
        return args[0]
70

  
71
    return "/".join([args[0].rstrip("/")] +
72
                    [a.lstrip("/") for a in args[1:-1]] +
73
                    [args[-1].lstrip("/")])
63 74

  
64 75

  
65 76
def parse_base_url(base_url):

Also available in: Unified diff