This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/util/string.py

14 lines
416 B
Python
Raw Normal View History

2015-12-22 14:55:13 -05:00
def slash_join(*args):
"""
Joins together strings and guarantees there is only one '/' in between the
each string joined. Double slashes ('//') are assumed to be intentional and
are not deduplicated.
"""
def rmslash(path):
path = path[1:] if path[0] == '/' else path
path = path[:-1] if path[-1] == '/' else path
return path
args = [rmslash(path) for path in args]
return '/'.join(args)