e115934061
Publish `@librechat/data-schemas` to NPM / pack (push) Failing after 8s
Publish `@librechat/client` to NPM / pack (push) Failing after 0s
GitNexus Index / index (push) Failing after 1s
Sync Locize Translations & Create Translation PR / Create Translation PR on Version Published (push) Has been skipped
Sync Helm Chart Tags / Sync chart tags (push) Failing after 2s
Publish `librechat-data-provider` to NPM / pack (push) Failing after 1s
Docker Dev Images Build / build (Dockerfile, librechat-dev, node) (push) Failing after 1s
Docker Dev Images Build / build (Dockerfile.multi, librechat-dev-api, api-build) (push) Failing after 0s
Sync Helm Chart Tags / Ignore non-main push (push) Has been skipped
Sync Locize Translations & Create Translation PR / Sync Translation Keys with Locize (push) Failing after 1s
Publish `@librechat/client` to NPM / publish-npm (push) Has been cancelled
Publish `librechat-data-provider` to NPM / publish-npm (push) Has been cancelled
GitNexus Index / post-index (push) Has been cancelled
Publish `@librechat/data-schemas` to NPM / publish-npm (push) Has been cancelled
32 lines
1.2 KiB
JavaScript
32 lines
1.2 KiB
JavaScript
jest.mock('sharp', () => jest.fn(), { virtual: true });
|
|
|
|
const { cleanFileName, getContentDisposition } = require('./files');
|
|
|
|
describe('file utilities', () => {
|
|
describe('cleanFileName', () => {
|
|
it('removes storage UUID prefixes', () => {
|
|
expect(cleanFileName('123e4567-e89b-12d3-a456-426614174000__report.txt')).toBe('report.txt');
|
|
});
|
|
});
|
|
|
|
describe('getContentDisposition', () => {
|
|
it('adds RFC 8187 encoding for Unicode filenames', () => {
|
|
const filename = '日本語レポート.xlsx';
|
|
const header = getContentDisposition(`123e4567-e89b-12d3-a456-426614174000__${filename}`);
|
|
|
|
expect(header).toMatch(/^attachment; filename=".*"; filename\*=UTF-8''/);
|
|
expect(header).not.toContain('123e4567-e89b-12d3-a456-426614174000__');
|
|
expect(header).toContain(`filename*=UTF-8''${encodeURIComponent(filename)}`);
|
|
});
|
|
|
|
it('escapes the ASCII fallback without dropping the encoded filename', () => {
|
|
const filename = 'bad"name\r\n.txt';
|
|
const header = getContentDisposition(filename);
|
|
|
|
expect(header).toContain('filename="bad_name__.txt"');
|
|
expect(header).toContain("filename*=UTF-8''bad%22name%0D%0A.txt");
|
|
expect(header).not.toMatch(/[\r\n]/);
|
|
});
|
|
});
|
|
});
|