Skip to content

Commit 61d94b2

Browse files
lng20206543
andauthored
Fix link-action redirect network error (#27734)
<img width="823" alt="image" src="https://github.com/go-gitea/gitea/assets/70063547/99da3d5a-c28a-4fd0-8ae0-88461a9142e2"> --------- Co-authored-by: 6543 <[email protected]>
1 parent f3956fc commit 61d94b2

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

routers/web/repo/milestone.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,15 @@ func EditMilestonePost(ctx *context.Context) {
231231

232232
// ChangeMilestoneStatus response for change a milestone's status
233233
func ChangeMilestoneStatus(ctx *context.Context) {
234-
toClose := false
234+
var toClose bool
235235
switch ctx.Params(":action") {
236236
case "open":
237237
toClose = false
238238
case "close":
239239
toClose = true
240240
default:
241-
ctx.Redirect(ctx.Repo.RepoLink + "/milestones")
241+
ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones")
242+
return
242243
}
243244
id := ctx.ParamsInt64(":id")
244245

@@ -250,7 +251,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
250251
}
251252
return
252253
}
253-
ctx.Redirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.Params(":action")))
254+
ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.Params(":action")))
254255
}
255256

256257
// DeleteMilestone delete a milestone

routers/web/repo/projects.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,15 @@ func NewProjectPost(ctx *context.Context) {
161161

162162
// ChangeProjectStatus updates the status of a project between "open" and "close"
163163
func ChangeProjectStatus(ctx *context.Context) {
164-
toClose := false
164+
var toClose bool
165165
switch ctx.Params(":action") {
166166
case "open":
167167
toClose = false
168168
case "close":
169169
toClose = true
170170
default:
171-
ctx.Redirect(ctx.Repo.RepoLink + "/projects")
171+
ctx.JSONRedirect(ctx.Repo.RepoLink + "/projects")
172+
return
172173
}
173174
id := ctx.ParamsInt64(":id")
174175

@@ -180,7 +181,7 @@ func ChangeProjectStatus(ctx *context.Context) {
180181
}
181182
return
182183
}
183-
ctx.Redirect(ctx.Repo.RepoLink + "/projects?state=" + url.QueryEscape(ctx.Params(":action")))
184+
ctx.JSONRedirect(ctx.Repo.RepoLink + "/projects?state=" + url.QueryEscape(ctx.Params(":action")))
184185
}
185186

186187
// DeleteProject delete a project

0 commit comments

Comments
 (0)