import posixpath


def route_name_to_path(route_name, prefix=None, add_slash=False):
    """Convert a route name to a URL path."""
    path = route_name.replace(".", "/")
    path = path.replace("_", "-")
    path = path.strip("/")
    path = f"/{path}"
    if prefix:
        path = posixpath.join(prefix, path.lstrip("/"))
    if add_slash:
        path = f"{path}/"
    return path