Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Fix local file open issue https://github.com/siyuan-note/siyuan/issues/14052

Danielea05b7285766
diff --git a/app/src/util/pathName.ts b/app/src/util/pathName.ts
index bd7b7b5e04..95eabaaa87 100644
--- a/app/src/util/pathName.ts
+++ b/app/src/util/pathName.ts
@@ -87,14 +87,22 @@ export const getAssetName = (assetPath: string) => {
};
export const isLocalPath = (link: string) => {
- link = link?.trim();
- if (!link || link.length === 0) {
+ if (!link) {
return false;
}
- // Windows 网络共享路径双斜杠
- // 冒号前面只有一个字母认为是 Windows 盘符而不是网络协议
- return /^assets\/|file:\/\/|\\\\|[A-Z]:$/i.test(link);
+ link = link.trim();
+ if (1 > link.length) {
+ return false;
+ }
+
+ link = link.toLowerCase();
+ if (link.startsWith("assets/") || link.startsWith("file://") || link.startsWith("\\\\") /* Windows 网络共享路径 */) {
+ return true;
+ }
+
+ const colonIdx = link.indexOf(":");
+ return 1 === colonIdx; // 冒号前面只有一个字符认为是 Windows 盘符而不是网络协议
};
export const pathPosix = () => {