chore: Fix app

This commit is contained in:
2026-07-14 00:41:05 +02:00
parent 3e090933fd
commit edc4d935d8
98 changed files with 2878 additions and 155 deletions
@@ -0,0 +1,31 @@
import {
describe,
expect,
it
} from 'vitest';
import { buildAttachmentExportFileName } from './attachment-export.rules';
describe('buildAttachmentExportFileName', () => {
it('appends the timestamp before the extension so exports never collide', () => {
expect(buildAttachmentExportFileName('report.pdf', 1_720_900_000_000)).toBe('report-1720900000000.pdf');
});
it('appends the timestamp at the end when there is no extension', () => {
expect(buildAttachmentExportFileName('README', 42)).toBe('README-42');
});
it('keeps dotfiles intact instead of treating the leading dot as an extension', () => {
expect(buildAttachmentExportFileName('.env', 42)).toBe('.env-42');
});
it('strips directory components from the filename', () => {
expect(buildAttachmentExportFileName('../secret/../../etc/passwd.txt', 7)).toBe('passwd-7.txt');
expect(buildAttachmentExportFileName('folder\\file.bin', 7)).toBe('file-7.bin');
});
it('falls back to a generic name when the filename is empty after sanitising', () => {
expect(buildAttachmentExportFileName(' ', 7)).toBe('attachment-7');
expect(buildAttachmentExportFileName('a/b/', 7)).toBe('attachment-7');
});
});