Skip to content

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

:art: Improve Liandi clipping (#15087)

Jeffrey Chen10df855457cc
diff --git a/kernel/api/extension.go b/kernel/api/extension.go
index fe24cf4940..97fa3e3cd8 100644
--- a/kernel/api/extension.go
+++ b/kernel/api/extension.go
@@ -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
}
}