✨ feat(vscode): 注释里的仓库图片按比例显示

This commit is contained in:
cruldra committed 2026-10-03 03:22:20 +08:00
1 parent 57b2f2a115
commit 9faf9cde9e
13 files changed
+312 -8

No files matched your search

+13 -1
View File
@@ -2,7 +2,7 @@ import { mkdir, mkdtemp, realpath, rm, symlink, writeFile } from 'node:fs/promis
import { tmpdir } from 'node:os'
import path from 'node:path'
import { describe, expect, it } from 'vitest'
import { findRepoSymbol, pathInsideRoot, resolveRepoEntry } from './repoPath'
import { findRepoSymbol, isRepoImagePath, pathInsideRoot, resolveRepoEntry } from './repoPath'
describe('pathInsideRoot', () => {
const root = '/repo'
@@ -21,6 +21,18 @@ describe('pathInsideRoot', () => {
})
})
describe('isRepoImagePath', () => {
it('仓库里的图片算,跑出去的和不是图片的不算', () => {
expect(isRepoImagePath('frontend/a.png')).toBe(true)
expect(isRepoImagePath('frontend/a.PNG')).toBe(true)
expect(isRepoImagePath('../a.png')).toBe(false)
expect(isRepoImagePath('./a.png')).toBe(false)
expect(isRepoImagePath('/a.png')).toBe(false)
expect(isRepoImagePath('C:/a.png')).toBe(false)
expect(isRepoImagePath('README.md')).toBe(false)
})
})
describe('findRepoSymbol', () => {
const tree = [
{