🐛 fix(vscode): 代码阅读注释里的链接指到别的文件时用预览打开,和 ⌘ 点击跳到定义走同一条路

This commit is contained in:
cruldra committed 2026-10-08 07:17:26 +08:00
1 parent e04a90c877
commit bc7380c716
9 files changed
+123 -72

No files matched your search

+1 -6
View File
@@ -33,14 +33,9 @@ export function isSafeRepoPath(rel: string): boolean {
/** 注释里当图片显示的文件后缀。webview 的 repoImage.ts 用同一份。 */
const IMAGE_FILE = /\.(?:avif|bmp|gif|ico|jpe?g|png|svg|webp)$/i
/** 文件名是图片。绝对路径也能用来判断,不检查有没有跑出仓库。 */
export function isImageFile(filePath: string): boolean {
return IMAGE_FILE.test(filePath)
}
/** 从仓库根起、能在注释里当图片显示的路径。别的仓库文件不给预览地址。 */
export function isRepoImagePath(rel: string): boolean {
return isSafeRepoPath(rel) && isImageFile(rel)
return isSafeRepoPath(rel) && IMAGE_FILE.test(rel)
}
/** target 解析之后还在 root 里面(root 自己不算)。 */