from typing import Optional
from typing import Match
from typing import Any
import re


def _valid_return_path(return_to: str) -> Optional[Match[Any]]:
    """Make sure this is a valid relative path to prevent redirect attacks."""
    return re.match(
        '^/[^/]',
        return_to,
    )