Преглед изворни кода

:art: Improve net assets to local assets https://github.com/siyuan-note/siyuan/issues/11885

Daniel пре 1 година
родитељ
комит
3073be676d
2 измењених фајлова са 11 додато и 0 уклоњено
  1. 3 0
      kernel/api/asset.go
  2. 8 0
      kernel/model/assets.go

+ 3 - 0
kernel/api/asset.go

@@ -53,6 +53,9 @@ func statAsset(c *gin.Context) {
 
 
 	} else if strings.HasPrefix(path, "file://") {
 	} else if strings.HasPrefix(path, "file://") {
 		p = strings.TrimPrefix(path, "file://")
 		p = strings.TrimPrefix(path, "file://")
+		if strings.Contains(p, ":") {
+			p = strings.TrimPrefix(p, "/")
+		}
 	} else {
 	} else {
 		ret.Code = 1
 		ret.Code = 1
 		return
 		return

+ 8 - 0
kernel/model/assets.go

@@ -125,6 +125,10 @@ func NetImg2LocalAssets(rootID, originalURL string) (err error) {
 					// `Convert network images/assets to local` supports URL-encoded local file names https://github.com/siyuan-note/siyuan/issues/9929
 					// `Convert network images/assets to local` supports URL-encoded local file names https://github.com/siyuan-note/siyuan/issues/9929
 					u = unescaped
 					u = unescaped
 				}
 				}
+				if strings.Contains(u, ":") {
+					u = strings.TrimPrefix(u, "/")
+				}
+
 				if !gulu.File.IsExist(u) || gulu.File.IsDir(u) {
 				if !gulu.File.IsExist(u) || gulu.File.IsDir(u) {
 					return ast.WalkSkipChildren
 					return ast.WalkSkipChildren
 				}
 				}
@@ -299,6 +303,10 @@ func NetAssets2LocalAssets(rootID string) (err error) {
 				// `Convert network images/assets to local` supports URL-encoded local file names https://github.com/siyuan-note/siyuan/issues/9929
 				// `Convert network images/assets to local` supports URL-encoded local file names https://github.com/siyuan-note/siyuan/issues/9929
 				u = unescaped
 				u = unescaped
 			}
 			}
+			if strings.Contains(u, ":") {
+				u = strings.TrimPrefix(u, "/")
+			}
+
 			if !gulu.File.IsExist(u) || gulu.File.IsDir(u) {
 			if !gulu.File.IsExist(u) || gulu.File.IsDir(u) {
 				return ast.WalkContinue
 				return ast.WalkContinue
 			}
 			}