Skip to content

Commit 5087de1

Browse files
GiteaBotlng20206543
authored
Fix link-action redirect network error (#27734) (#27749)
Backport #27734 by @lng2020 <img width="823" alt="image" src="https://github.com/go-gitea/gitea/assets/70063547/99da3d5a-c28a-4fd0-8ae0-88461a9142e2"> Co-authored-by: Nanguan Lin <[email protected]> Co-authored-by: 6543 <[email protected]>
1 parent f2bac79 commit 5087de1

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
@@ -225,14 +225,15 @@ func EditMilestonePost(ctx *context.Context) {
225225

226226
// ChangeMilestoneStatus response for change a milestone's status
227227
func ChangeMilestoneStatus(ctx *context.Context) {
228-
toClose := false
228+
var toClose bool
229229
switch ctx.Params(":action") {
230230
case "open":
231231
toClose = false
232232
case "close":
233233
toClose = true
234234
default:
235-
ctx.Redirect(ctx.Repo.RepoLink + "/milestones")
235+
ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones")
236+
return
236237
}
237238
id := ctx.ParamsInt64(":id")
238239

@@ -244,7 +245,7 @@ func ChangeMilestoneStatus(ctx *context.Context) {
244245
}
245246
return
246247
}
247-
ctx.Redirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.Params(":action")))
248+
ctx.JSONRedirect(ctx.Repo.RepoLink + "/milestones?state=" + url.QueryEscape(ctx.Params(":action")))
248249
}
249250

250251
// 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)