| 29 | |
| 30 | |
| 31 | def normalized_github_host(raw: object) -> str | None: |
| 32 | if raw is None or raw == "": |
| 33 | return GITHUB_COPILOT_DEFAULT_HOST |
| 34 | if not isinstance(raw, str): |
| 35 | return None |
| 36 | |
| 37 | host: Final = raw.lower() |
| 38 | if host == GITHUB_COPILOT_DEFAULT_HOST: |
| 39 | return host |
| 40 | if not host.endswith(".ghe.com"): |
| 41 | return None |
| 42 | |
| 43 | subdomain: Final = host.removesuffix(".ghe.com") |
| 44 | return host if _GHE_SUBDOMAIN_PATTERN.fullmatch(subdomain) is not None else None |
| 45 | |
| 46 | |
| 47 | def github_host_endpoints(host: str) -> GithubHostEndpoints: |