~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/urlutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-05-02 20:52:40 UTC
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060502205240-dff94572278b6aba
s comes before u

Show diffs side-by-side

added added

removed removed

Lines of Context:
107
107
    MIN_ABS_URLPATHLENGTH = len('file:///C|/')
108
108
 
109
109
 
 
110
def strip_trailing_slash(url):
 
111
    """Strip trailing slash, except for root paths.
 
112
 
 
113
    The definition of 'root path' is platform-dependent.
 
114
    But the passed in URL must be a file:/// url.
 
115
    """
 
116
    assert url.startswith('file:///'), \
 
117
        'strip_trailing_slash expects file:// urls (%s)' % url
 
118
    if len(url) != MIN_ABS_URLPATHLENGTH and url[-1] == '/':
 
119
        return url[:-1]
 
120
    else:
 
121
        return url
 
122
 
 
123
 
110
124
def unescape(url):
111
125
    """Unescape relpath from url format.
112
126
 
173
187
    return '/'.join(res)
174
188
 
175
189
 
176
 
def strip_trailing_slash(url):
177
 
    """Strip trailing slash, except for root paths.
178
 
 
179
 
    The definition of 'root path' is platform-dependent.
180
 
    But the passed in URL must be a file:/// url.
181
 
    """
182
 
    assert url.startswith('file:///'), \
183
 
        'strip_trailing_slash expects file:// urls (%s)' % url
184
 
    if len(url) != MIN_ABS_URLPATHLENGTH and url[-1] == '/':
185
 
        return url[:-1]
186
 
    else:
187
 
        return url
188
 
 
189