fix:slice越界

This commit is contained in:
www.xueximeng.com
2025-10-27 17:11:41 +08:00
parent d057ef481e
commit f5bc0baa4c

View File

@@ -816,7 +816,12 @@ func extractLinkTitlePairsWithoutNewlines(content string) map[string]string {
// 查找每个链接的位置,并提取链接前的文本作为段落
for i, link := range links {
pos := strings.Index(content[lastPos:], link) + lastPos
idx := strings.Index(content[lastPos:], link)
if idx == -1 {
// 链接在content中不存在跳过
continue
}
pos := idx + lastPos
if pos > lastPos {
segments[i] = content[lastPos:pos]
}