Skip to content

Commit bef3ad4

Browse files
SupenByszclaude
andcommitted
fix: Wiki API 紧急 bug 修复
修复两个 P0 级别的 Wiki API bug: 1. 修复 PATCH /wiki/page/{pageName} 总是更新 "unnamed" 页面的问题 - 原因: 当 form.Title 为空时,UserTitleToWebPath("", "") 会返回默认值 "unnamed" - 解决: 在调用 UserTitleToWebPath 前先检查 form.Title 是否为空,为空则直接使用路径参数中的页面名 2. 修复 GET /wiki/revisions/{pageName} 返回对象而非数组的问题 - 原因: 使用了 convert.ToWikiCommitList() 将数组包装成了 {commits: [...], count: N} 对象 - 解决: 直接返回 []*api.WikiCommit 数组,保持 RESTful 规范 - 总数仍通过 X-Total-Count HTTP header 提供 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 77b8059 commit bef3ad4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

routers/api/v1/repo/wiki.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,13 @@ func EditWikiPage(ctx *context.APIContext) {
137137
form := web.GetForm(ctx).(*api.CreateWikiPageOptions)
138138

139139
oldWikiName := wiki_service.WebPathFromRequest(ctx.PathParamRaw("pageName"))
140-
newWikiName := wiki_service.UserTitleToWebPath("", form.Title)
141140

142-
if len(newWikiName) == 0 {
141+
// If no new title is provided, keep the original page name
142+
var newWikiName wiki_service.WebPath
143+
if form.Title == "" {
143144
newWikiName = oldWikiName
145+
} else {
146+
newWikiName = wiki_service.UserTitleToWebPath("", form.Title)
144147
}
145148

146149
if len(form.Message) == 0 {
@@ -445,8 +448,14 @@ func ListPageRevisions(ctx *context.APIContext) {
445448
return
446449
}
447450

451+
// Convert commits to API format
452+
result := make([]*api.WikiCommit, len(commitsHistory))
453+
for i := range commitsHistory {
454+
result[i] = convert.ToWikiCommit(commitsHistory[i])
455+
}
456+
448457
ctx.SetTotalCountHeader(commitsCount)
449-
ctx.JSON(http.StatusOK, convert.ToWikiCommitList(commitsHistory, commitsCount))
458+
ctx.JSON(http.StatusOK, result)
450459
}
451460

452461
// findEntryForFile finds the tree entry for a target filepath.

0 commit comments

Comments
 (0)