瀏覽代碼

:bug: 搜索指定路径参数解析异常 Fix https://github.com/siyuan-note/siyuan/issues/6983

Liang Ding 2 年之前
父節點
當前提交
7690ca7c05
共有 1 個文件被更改,包括 8 次插入4 次删除
  1. 8 4
      kernel/api/search.go

+ 8 - 4
kernel/api/search.go

@@ -201,10 +201,14 @@ func fullTextSearchBlock(c *gin.Context) {
 	if nil != pathsArg {
 		for _, p := range pathsArg.([]interface{}) {
 			path := p.(string)
-			box := strings.Split(path, "/")[0]
-			boxes = append(boxes, box)
-			path = strings.TrimPrefix(path, box)
-			paths = append(paths, path)
+			box := strings.TrimSpace(strings.Split(path, "/")[0])
+			if "" != box {
+				boxes = append(boxes, box)
+			}
+			path = strings.TrimSpace(strings.TrimPrefix(path, box))
+			if "" != path {
+				paths = append(paths, path)
+			}
 		}
 		paths = gulu.Str.RemoveDuplicatedElem(paths)
 		boxes = gulu.Str.RemoveDuplicatedElem(boxes)