6 lines
317 B
TypeScript
6 lines
317 B
TypeScript
export function buildContentDisposition(type: 'inline' | 'attachment', fileName: string) {
|
|
const asciiFallback = fileName.replace(/[^\x20-\x7E]+/g, '_').replace(/["\\]/g, '_') || 'file';
|
|
const encoded = encodeURIComponent(fileName);
|
|
return `${type}; filename="${asciiFallback}"; filename*=UTF-8''${encoded}`;
|
|
}
|