🎨 Improve Liandi clipping (#15087)

* 🐛 Improve Liandi clipping

fix https://github.com/siyuan-note/siyuan/issues/15086

* 🐛 Improve Liandi clipping

fix https://github.com/siyuan-note/siyuan/issues/15086
This commit is contained in:
Jeffrey Chen 2025-06-19 10:32:04 +08:00 committed by GitHub
parent 743f4eecbf
commit 10df855457
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,13 +62,32 @@ func extensionCopy(c *gin.Context) {
clippingSym := false
symArticleHref := ""
if nil != form.Value["href"] {
hasHref := nil != form.Value["href"]
isPartClip := nil != form.Value["clipType"] && form.Value["clipType"][0] == "part"
if hasHref && !isPartClip {
// 剪藏链滴帖子时直接使用 Markdown 接口的返回
// https://ld246.com/article/raw/1724850322251
symArticleHref = form.Value["href"][0]
if strings.HasPrefix(symArticleHref, "https://ld246.com/article/") || strings.HasPrefix(symArticleHref, "https://liuyun.io/article/") {
symArticleHref = strings.ReplaceAll(symArticleHref, "https://ld246.com/article/", "https://ld246.com/article/raw/")
symArticleHref = strings.ReplaceAll(symArticleHref, "https://liuyun.io/article/", "https://liuyun.io/article/raw/")
var baseURL, originalPrefix string
if strings.HasPrefix(symArticleHref, "https://ld246.com/article/") {
baseURL = "https://ld246.com/article/raw/"
originalPrefix = "https://ld246.com/article/"
} else if strings.HasPrefix(symArticleHref, "https://liuyun.io/article/") {
baseURL = "https://liuyun.io/article/raw/"
originalPrefix = "https://liuyun.io/article/"
}
if "" != baseURL {
articleID := strings.TrimPrefix(symArticleHref, originalPrefix)
if idx := strings.IndexAny(articleID, "/?#"); -1 != idx {
articleID = articleID[:idx]
}
symArticleHref = baseURL + articleID
clippingSym = true
}
}