(raw: string | null | undefined)
| 342 | } |
| 343 | |
| 344 | function normalizeOrigin(raw: string | null | undefined): string | null { |
| 345 | if (!raw) { |
| 346 | return null; |
| 347 | } |
| 348 | |
| 349 | try { |
| 350 | const parsed = new URL(raw); |
| 351 | const normalizedProtocol = normalizeProtocol(parsed.protocol); |
| 352 | |
| 353 | if (!normalizedProtocol) { |
| 354 | return null; |
| 355 | } |
| 356 | |
| 357 | return `${normalizedProtocol}://${parsed.host}`; |
| 358 | } catch { |
| 359 | return null; |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | interface OriginIdentity { |
| 364 | protocol: "http:" | "https:"; |
no test coverage detected