Skip to content

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

:art: Improve network image convert to local image https://github.com/siyuan-note/siyuan/issues/12561

Danielef575a1560d5
diff --git a/kernel/model/assets.go b/kernel/model/assets.go
index e913193314..34f67ccd6a 100644
--- a/kernel/model/assets.go
+++ b/kernel/model/assets.go
@@ -1057,10 +1057,19 @@ func assetsLinkDestsInNode(node *ast.Node) (ret []string) {
func setAssetsLinkDest(node *ast.Node, oldDest, dest string) {
if ast.NodeLinkDest == node.Type {
+ if bytes.HasPrefix(node.Tokens, []byte("//")) {
+ node.Tokens = append([]byte("https:"), node.Tokens...)
+ }
node.Tokens = bytes.ReplaceAll(node.Tokens, []byte(oldDest), []byte(dest))
} else if node.IsTextMarkType("a") {
+ if strings.HasPrefix(node.TextMarkAHref, "//") {
+ node.TextMarkAHref = "https:" + node.TextMarkAHref
+ }
node.TextMarkAHref = strings.ReplaceAll(node.TextMarkAHref, oldDest, dest)
} else if ast.NodeAudio == node.Type || ast.NodeVideo == node.Type {
+ if strings.HasPrefix(node.TextMarkAHref, "//") {
+ node.TextMarkAHref = "https:" + node.TextMarkAHref
+ }
node.Tokens = bytes.ReplaceAll(node.Tokens, []byte(oldDest), []byte(dest))
} else if ast.NodeAttributeView == node.Type {
needWrite := false