feat(workspace): 完成图片资产存储与引用
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user