15 lines
768 B
TypeScript
15 lines
768 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { resolveWorkspaceAssetPath, workspaceAssetReference } from './workspaceService'
|
|
|
|
describe('workspace asset paths', () => {
|
|
it('creates portable references relative to the note', () => {
|
|
expect(workspaceAssetReference('/课程/系统/调度.md', 'attachments/ab/hash.png')).toBe('../../attachments/ab/hash.png')
|
|
expect(resolveWorkspaceAssetPath('/课程/系统/调度.md', '../../attachments/ab/hash.png')).toBe('attachments/ab/hash.png')
|
|
})
|
|
|
|
it('does not resolve remote URLs or paths escaping the vault', () => {
|
|
expect(resolveWorkspaceAssetPath('/a.md', 'https://example.com/image.png')).toBeNull()
|
|
expect(resolveWorkspaceAssetPath('/a.md', '../attachments/ab/hash.png')).toBeNull()
|
|
})
|
|
})
|