This commit is contained in:
Daniel 2025-02-13 11:14:26 +08:00
parent c45a02643e
commit ea05b72857
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -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 = () => {