一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
22 行
938 B
TypeScript
22 行
938 B
TypeScript
import { ResourceEntity } from '../../services/database/types';
|
|
import { resourceFilename } from './resourceUtils';
|
|
|
|
describe('resourceUtils', () => {
|
|
|
|
it('should build a filename from id and extension', () => {
|
|
const resource: ResourceEntity = { id: '00000000000000000000000000000001', file_extension: 'txt' };
|
|
expect(resourceFilename(resource)).toBe('00000000000000000000000000000001.txt');
|
|
});
|
|
|
|
it.each([
|
|
{ id: '../../escape', file_extension: 'txt' },
|
|
{ id: 'foo/bar', file_extension: 'txt' },
|
|
{ id: '00000000000000000000000000000001', file_extension: '../foo.txt' },
|
|
{ id: '00000000000000000000000000000001', file_extension: 'foo/bar' },
|
|
{ id: '00000000000000000000000000000001', file_extension: 'foo\\bar' },
|
|
])('should reject filenames containing path separators or parent segments (%j)', (resource) => {
|
|
expect(() => resourceFilename(resource as ResourceEntity)).toThrow(/Invalid resource filename/);
|
|
});
|
|
|
|
});
|