(origin: string | undefined)
| 52 | * or `undefined` when the origin is missing or malformed. |
| 53 | */ |
| 54 | export function originHost(origin: string | undefined): string | undefined { |
| 55 | if (origin === undefined) { |
| 56 | return undefined; |
| 57 | } |
| 58 | try { |
| 59 | return new URL(origin).host; |
| 60 | } catch { |
| 61 | return undefined; |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Decide whether an `Origin` is allowed for a request to `host`. |
no outgoing calls
no test coverage detected