def redirect_script() -> str:
    """Get the redirect script for Github Codespaces.

    Returns:
        The redirect script as a string.
    """
    return f"""
const thisUrl = new URL(window.location.href);
const params = new URLSearchParams(thisUrl.search)

function doRedirect(url) {{
    if (!window.sessionStorage.getItem("authenticated_github_codespaces")) {{
        const a = document.createElement("a");
        if (params.has("redirect_to")) {{
            a.href = params.get("redirect_to")
        }} else if (!window.location.href.startsWith(url)) {{
            a.href = url + `?redirect_to=${{window.location.href}}`
        }} else {{
            return
        }}
        a.hidden = true;
        a.click();
        a.remove();
        window.sessionStorage.setItem("authenticated_github_codespaces", "true")
    }}
}}
doRedirect("{Endpoint.AUTH_CODESPACE.get_url()}")
"""
Get the redirect script for Github Codespaces.

    Returns:
        The redirect script as a string.
    
reflex/utils/codespaces.py