def rel_path(path: str, source_name: str, source_prefix: str) -> str:
    """Returns relative path by removing prefix and replacing base name."""
    relative_path = path.removeprefix(source_prefix)
    base, _, _ = relative_path.partition("/")
    relative_path = relative_path.replace(base, source_name)
    return relative_path