(contentType: string)
| 123 | * Text-ish types (text/*, json, xml, form data) are treated as non-binary. |
| 124 | */ |
| 125 | export function isBinaryContentType(contentType: string): boolean { |
| 126 | if (!contentType) return false |
| 127 | const mt = (contentType.split(';')[0] ?? '').trim().toLowerCase() |
| 128 | if (mt.startsWith('text/')) return false |
| 129 | // Structured text formats delivered with an application/ type. Use suffix |
| 130 | // or exact match rather than substring so 'openxmlformats' (docx/xlsx) stays binary. |
| 131 | if (mt.endsWith('+json') || mt === 'application/json') return false |
| 132 | if (mt.endsWith('+xml') || mt === 'application/xml') return false |
| 133 | if (mt.startsWith('application/javascript')) return false |
| 134 | if (mt === 'application/x-www-form-urlencoded') return false |
| 135 | return true |
| 136 | } |
| 137 | |
| 138 | export type PersistBinaryResult = |
| 139 | | { filepath: string; size: number; ext: string } |
no outgoing calls
no test coverage detected