(name: string, mediaType?: string)
| 307 | } |
| 308 | |
| 309 | function buildContentDisposition(name: string, mediaType?: string): string { |
| 310 | // Media the browser can render (image/video/audio) is served `inline` so a |
| 311 | // direct navigation plays/displays it; everything else stays an attachment. |
| 312 | const kind = mediaType?.split('/')[0]; |
| 313 | const disposition = |
| 314 | kind === 'image' || kind === 'video' || kind === 'audio' ? 'inline' : 'attachment'; |
| 315 | if (/^[\w. ()+[\]-]+$/.test(name)) { |
| 316 | return `${disposition}; filename="${name}"`; |
| 317 | } |
| 318 | return disposition; |
| 319 | } |
| 320 | |
| 321 | function readRangeHeader(value: string | string[] | undefined): string | undefined { |
| 322 | return Array.isArray(value) ? value[0] : value; |
no outgoing calls
no test coverage detected