Skip to content

Commit

Permalink
🎨 Convert network images to local supports // #10598
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Mar 14, 2024
1 parent d1009f2 commit 8d290fb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions kernel/model/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,12 @@ func NetImg2LocalAssets(rootID, originalURL string) (err error) {
return ast.WalkSkipChildren
}

if bytes.HasPrefix(bytes.ToLower(dest), []byte("https://")) || bytes.HasPrefix(bytes.ToLower(dest), []byte("http://")) {
if bytes.HasPrefix(bytes.ToLower(dest), []byte("https://")) || bytes.HasPrefix(bytes.ToLower(dest), []byte("http://")) || bytes.HasPrefix(dest, []byte("//")) {
if bytes.HasPrefix(dest, []byte("//")) {
// `Convert network images to local` supports `//` /~https://github.com/siyuan-note/siyuan/issues/10598
dest = append([]byte("https:"), dest...)
}

u := string(dest)
if strings.Contains(u, "qpic.cn") {
// 改进 `网络图片转换为本地图片` 微信图片拉取 /~https://github.com/siyuan-note/siyuan/issues/5052
Expand Down Expand Up @@ -320,7 +325,12 @@ func NetAssets2LocalAssets(rootID string) (err error) {
return ast.WalkContinue
}

if bytes.HasPrefix(bytes.ToLower(dest), []byte("https://")) || bytes.HasPrefix(bytes.ToLower(dest), []byte("http://")) {
if bytes.HasPrefix(bytes.ToLower(dest), []byte("https://")) || bytes.HasPrefix(bytes.ToLower(dest), []byte("http://")) || bytes.HasPrefix(dest, []byte("//")) {
if bytes.HasPrefix(dest, []byte("//")) {
// `Convert network images to local` supports `//` /~https://github.com/siyuan-note/siyuan/issues/10598
dest = append([]byte("https:"), dest...)
}

u := string(dest)
if strings.Contains(u, "qpic.cn") {
// 改进 `网络图片转换为本地图片` 微信图片拉取 /~https://github.com/siyuan-note/siyuan/issues/5052
Expand Down

0 comments on commit 8d290fb

Please sign in to comment.