(rawHost: unknown)
| 46 | * @throws {UnsafeGitLabHostError} when a non-empty host is structurally unsafe. |
| 47 | */ |
| 48 | export function normalizeGitLabHost(rawHost: unknown): string { |
| 49 | const raw = typeof rawHost === 'string' ? rawHost.trim() : '' |
| 50 | if (!raw) return DEFAULT_GITLAB_HOST |
| 51 | const host = raw |
| 52 | .replace(/^https?:\/\//i, '') |
| 53 | .replace(/\/+$/, '') |
| 54 | .trim() |
| 55 | if (!host) return DEFAULT_GITLAB_HOST |
| 56 | assertSafeGitLabHostString(host, String(rawHost)) |
| 57 | return host |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * Builds the REST API v4 base URL for the configured host. Defaults to |
no test coverage detected