mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-04 15:58:49 +01:00
🐛 Fix local file open issue https://github.com/siyuan-note/siyuan/issues/14052
This commit is contained in:
parent
c45a02643e
commit
ea05b72857
1 changed files with 13 additions and 5 deletions
|
|
@ -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 = () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue