mirror of
https://github.com/nexu-io/open-design.git
synced 2026-05-31 19:04:39 +07:00
31 lines
973 B
TypeScript
31 lines
973 B
TypeScript
import path from 'node:path';
|
|
import { describe, expect, it } from 'vitest';
|
|
import { resolveSafeProjectAttachments } from '../src/server.js';
|
|
|
|
describe('resolveSafeProjectAttachments', () => {
|
|
it('keeps Windows attachments when root and attachment path use different separators and drive casing', () => {
|
|
const existing = new Set([
|
|
'C:\\Users\\Designer\\Open Design\\m5-logo.png',
|
|
'c:\\users\\designer\\open design\\assets\\mark.png',
|
|
]);
|
|
|
|
const safe = resolveSafeProjectAttachments(
|
|
'C:/Users/Designer/Open Design/',
|
|
[
|
|
'm5-logo.png',
|
|
'c:/users/designer/open design/assets/mark.png',
|
|
'C:/Users/Designer/Open Design Adjacent/secret.png',
|
|
'..\\secret.png',
|
|
],
|
|
{
|
|
existsSync: (target: string) => existing.has(target),
|
|
pathImpl: path.win32,
|
|
},
|
|
);
|
|
|
|
expect(safe).toEqual([
|
|
'm5-logo.png',
|
|
'c:/users/designer/open design/assets/mark.png',
|
|
]);
|
|
});
|
|
});
|