Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify url_join

  • Loading branch information...
commit f092a84ceb9ee984ef981b1bb533626e1fd90abb 1 parent f15b4b2
@k21 authored
Showing with 6 additions and 11 deletions.
  1. +6 −11 r2/r2/lib/utils/utils.py
View
17 r2/r2/lib/utils/utils.py
@@ -1379,23 +1379,18 @@ def url_join(*parts):
an absolute path, ignore all components in front of it.
"""
- #remove empty parts
- parts = filter(None, parts)
-
- if len(parts) == 0: return ''
-
path = []
- if parts[0].startswith('/'): path = ['/']
- path.append(parts[0].strip('/'))
- if parts[0].endswith('/'): path.append('/')
- for p in parts[1:]:
+ for p in parts:
+ if p == '': continue
if p.startswith('/'):
path = ['/']
- elif not path[-1].endswith('/'): path.append('/')
+ if len(path) != 0 and not path[-1].endswith('/'):
+ path.append('/')
stripped = p.strip('/')
if stripped:
path.append(stripped)
- if p.endswith('/'): path.append('/')
+ if p.endswith('/'):
+ path.append('/')
return ''.join(path)

0 comments on commit f092a84

Please sign in to comment.
Something went wrong with that request. Please try again.