Files
aigen/shared/content-disposition.mjs
T

8 lines
491 B
JavaScript

/** ASCII header fallback plus UTF-8 filename; titles may contain emoji or smart punctuation. */
export function inlineFilename(name) {
const clean=String(name).replace(/[\r\n\x00-\x1f\x7f]/g,'').toWellFormed()
const ascii=clean.replace(/[^\x20-\x7e]/g,'_').replace(/["\\]/g,'_') || 'video.mp4'
const encoded=encodeURIComponent(clean || 'video.mp4').replace(/['()*]/g,c=>'%'+c.charCodeAt(0).toString(16).toUpperCase())
return `inline; filename="${ascii}"; filename*=UTF-8''${encoded}`
}