from urllib.parse import urlsplit

from .constants import ALLOWED_REDIRECT_SCHEMES

def validate_redirect_url(url: str) -> str:
  parts = urlsplit(url)
  if parts.scheme not in ALLOWED_REDIRECT_SCHEMES:
    raise ValueError("decoded URL uses an unsupported redirect scheme")
  if not parts.netloc:
    raise ValueError("decoded URL has no host")
  return url
