def slash_join(a, b):
    """
    Join a and b with a single slash, regardless of whether they already
    contain a trailing/leading slash or neither.
    """
    if not b:
        return a
    if a.endswith('/'):
        if b.startswith('/'):
            return a[:-1] + b
        return a + b
    if b.startswith('/'):
        return a + b
    return a + '/' + b
