mirror of
https://github.com/docmost/docmost.git
synced 2026-05-17 06:44:05 +08:00
90 lines
3.2 KiB
TypeScript
90 lines
3.2 KiB
TypeScript
import { sanitizeFileName } from './utils';
|
|
|
|
describe('sanitizeFileName', () => {
|
|
describe('default (storage-safe)', () => {
|
|
it.each([
|
|
['simple.txt', 'simple.txt'],
|
|
['my page.md', 'my_page.md'],
|
|
['hash#tag.md', 'hash_tag.md'],
|
|
['Q4 25% growth.pdf', 'Q4_25%_growth.pdf'],
|
|
['résumé.docx', 'résumé.docx'],
|
|
])('keeps legitimate input "%s" → "%s"', (input, expected) => {
|
|
expect(sanitizeFileName(input)).toBe(expected);
|
|
});
|
|
|
|
it.each([
|
|
['file<script>.svg', 'filescript.svg'],
|
|
['file:name?.pdf', 'filename.pdf'],
|
|
['evil*pipe|file.txt', 'evilpipefile.txt'],
|
|
['../traversal.svg', '..traversal.svg'],
|
|
['..\\windows.svg', '..windows.svg'],
|
|
['null |