mirror of
https://github.com/go-gitea/gitea.git
synced 2026-11-05 00:09:33 +09:00
fix(api): keep wiki page name when editing with an empty title (#40153)
Match `PATCH /repos/{owner}/{repo}/wiki/page/{pageName}` document "leave
empty to keep unchanged"
Fixes #39179
---------
Co-authored-by: silverwind <me@silverwind.io>
This commit is contained in:
1 parent
5c68ba3e0a
commit
f26a314636
3 files changed
+28
-12
No files matched your search
@@ -49,6 +49,11 @@ func NewWikiPage(ctx *context.APIContext) {
|
||||
// "$ref": "#/responses/error"
|
||||
|
||||
form := web.GetForm[*api.CreateWikiPageOptions](ctx)
|
||||
// EditWikiPage shares the form but allows an empty title
|
||||
if form.Title == "" {
|
||||
ctx.APIError(http.StatusUnprocessableEntity, "title is required")
|
||||
return
|
||||
}
|
||||
wikiName := wiki_service.UserTitleToWebPath("", form.Title)
|
||||
|
||||
if len(form.Message) == 0 {
|
||||
@@ -117,10 +122,9 @@ func EditWikiPage(ctx *context.APIContext) {
|
||||
form := web.GetForm[*api.CreateWikiPageOptions](ctx)
|
||||
|
||||
oldWikiName := wiki_service.WebPathFromRequest(ctx.PathParamRaw("pageName"))
|
||||
newWikiName := wiki_service.UserTitleToWebPath("", form.Title)
|
||||
|
||||
if len(newWikiName) == 0 {
|
||||
newWikiName = oldWikiName
|
||||
newWikiName := oldWikiName
|
||||
if form.Title != "" {
|
||||
newWikiName = wiki_service.UserTitleToWebPath("", form.Title)
|
||||
}
|
||||
|
||||
if len(form.Message) == 0 {
|
||||
|
||||
Reference in new issue
Block a user