(request: Request)
| 163 | * cross-site POST; this is the belt to that pair of braces. |
| 164 | */ |
| 165 | export function isSameOriginPost(request: Request): boolean { |
| 166 | const origin = request.headers.get('origin'); |
| 167 | if (!origin) return true; // Absent on some legitimate non-browser clients (curl). |
| 168 | try { |
| 169 | return new URL(origin).host === new URL(request.url).host; |
| 170 | } catch { |
| 171 | return false; |
| 172 | } |
| 173 | } |
no test coverage detected