Fix Windows local file download paths (#810)
This commit is contained in:
@@ -238,6 +238,21 @@ describe('MarkdownRenderer', () => {
|
||||
expect(wrapper.find('.markdown-video-footer .att-name').text()).toBe('录屏2026-05-08 15.19.46.mov')
|
||||
})
|
||||
|
||||
it('renders MSYS-style Windows image paths through the download endpoint', () => {
|
||||
const wrapper = mount(MarkdownRenderer, {
|
||||
props: {
|
||||
content: '',
|
||||
},
|
||||
})
|
||||
|
||||
const img = wrapper.find('img')
|
||||
expect(img.exists()).toBe(true)
|
||||
expect(img.attributes('src')).toContain('/api/hermes/download?path=')
|
||||
const src = new URL(img.attributes('src'))
|
||||
expect(decodeURIComponent(src.searchParams.get('path') || '')).toBe('/c/Users/Administrator/Desktop/screenshot.png')
|
||||
expect(img.attributes('alt')).toBe('桌面截图')
|
||||
})
|
||||
|
||||
it('keeps tilde-fenced markdown examples with nested tilde fences intact', () => {
|
||||
const wrapper = mount(MarkdownRenderer, {
|
||||
props: {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { normalizePlatformPath } from '../../packages/server/src/services/hermes/file-provider'
|
||||
|
||||
describe('file provider platform path normalization', () => {
|
||||
it('converts MSYS drive paths to Windows absolute paths on Windows', () => {
|
||||
expect(normalizePlatformPath('/c/Users/Administrator/Desktop/screenshot.png', 'win32'))
|
||||
.toBe('C:\\Users\\Administrator\\Desktop\\screenshot.png')
|
||||
expect(normalizePlatformPath('/d/tmp/report.txt', 'win32'))
|
||||
.toBe('D:\\tmp\\report.txt')
|
||||
})
|
||||
|
||||
it('leaves MSYS-style paths unchanged on non-Windows platforms', () => {
|
||||
expect(normalizePlatformPath('/c/Users/Administrator/Desktop/screenshot.png', 'darwin'))
|
||||
.toBe('/c/Users/Administrator/Desktop/screenshot.png')
|
||||
expect(normalizePlatformPath('/c/Users/Administrator/Desktop/screenshot.png', 'linux'))
|
||||
.toBe('/c/Users/Administrator/Desktop/screenshot.png')
|
||||
})
|
||||
|
||||
it('leaves normal Windows paths unchanged', () => {
|
||||
expect(normalizePlatformPath('C:\\Users\\Administrator\\Desktop\\screenshot.png', 'win32'))
|
||||
.toBe('C:\\Users\\Administrator\\Desktop\\screenshot.png')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user