Files
ONE-OS/axhub-make/vite-plugins/utils/contentDisposition.ts
王冕 a27e3b8e43 feat: sync full workspace including web modules, docs, and configurations to Gitea
Optimized the root .gitignore to exclude virtual environments, node modules,
and temp folders to ensure clean and lightweight version tracking.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-09 18:12:25 +08:00

23 lines
690 B
TypeScript

function encodeRFC5987Value(value: string): string {
return encodeURIComponent(value).replace(/['()*]/g, (char) =>
`%${char.charCodeAt(0).toString(16).toUpperCase()}`,
);
}
function createAsciiFallback(fileName: string): string {
const normalized = fileName
.normalize('NFKD')
.replace(/[^\x20-\x7E]+/g, '_')
.replace(/["\\;%]/g, '_')
.replace(/\s+/g, ' ')
.trim();
return normalized || 'download';
}
export function buildAttachmentContentDisposition(fileName: string): string {
const fallback = createAsciiFallback(fileName);
const encoded = encodeRFC5987Value(fileName);
return `attachment; filename="${fallback}"; filename*=UTF-8''${encoded}`;
}