(protocol: string, host: string)
| 202 | } |
| 203 | |
| 204 | function buildOrigin(protocol: string, host: string): string | null { |
| 205 | const normalizedProtocol = normalizeProtocol(protocol); |
| 206 | const normalizedHost = host.trim(); |
| 207 | |
| 208 | if (!normalizedProtocol || normalizedHost.length === 0) { |
| 209 | return null; |
| 210 | } |
| 211 | |
| 212 | try { |
| 213 | return new URL(`${normalizedProtocol}://${normalizedHost}`).origin; |
| 214 | } catch { |
| 215 | return null; |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | function normalizeHostForProtocol(host: string, protocol: "http" | "https"): string | null { |
| 220 | const trimmedHost = host.trim(); |
no test coverage detected