Skip to content

Commit 8f89e1e

Browse files
GiteaBotlunny
andauthored
Fix atom/rss mixed error (#35345) (#35347)
Backport #35345 by @lunny Fix #35342 Co-authored-by: Lunny Xiao <[email protected]>
1 parent cbc595b commit 8f89e1e

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

routers/web/feed/render.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,18 @@ import (
88
)
99

1010
// RenderBranchFeed render format for branch or file
11-
func RenderBranchFeed(ctx *context.Context) {
12-
_, showFeedType := GetFeedType(ctx.PathParam("reponame"), ctx.Req)
11+
func RenderBranchFeed(ctx *context.Context, feedType string) {
1312
if ctx.Repo.TreePath == "" {
14-
ShowBranchFeed(ctx, ctx.Repo.Repository, showFeedType)
13+
ShowBranchFeed(ctx, ctx.Repo.Repository, feedType)
1514
} else {
16-
ShowFileFeed(ctx, ctx.Repo.Repository, showFeedType)
15+
ShowFileFeed(ctx, ctx.Repo.Repository, feedType)
1716
}
1817
}
18+
19+
func RenderBranchFeedRSS(ctx *context.Context) {
20+
RenderBranchFeed(ctx, "rss")
21+
}
22+
23+
func RenderBranchFeedAtom(ctx *context.Context) {
24+
RenderBranchFeed(ctx, "atom")
25+
}

routers/web/web.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,8 +1592,8 @@ func registerWebRoutes(m *web.Router) {
15921592
m.Get("/cherry-pick/{sha:([a-f0-9]{7,64})$}", repo.SetEditorconfigIfExists, context.RepoRefByDefaultBranch(), repo.CherryPick)
15931593
}, repo.MustBeNotEmpty)
15941594

1595-
m.Get("/rss/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeed)
1596-
m.Get("/atom/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeed)
1595+
m.Get("/rss/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeedRSS)
1596+
m.Get("/atom/branch/*", context.RepoRefByType(git.RefTypeBranch), feedEnabled, feed.RenderBranchFeedAtom)
15971597

15981598
m.Group("/src", func() {
15991599
m.Get("", func(ctx *context.Context) { ctx.Redirect(ctx.Repo.RepoLink) }) // there is no "{owner}/{repo}/src" page, so redirect to "{owner}/{repo}" to avoid 404

0 commit comments

Comments
 (0)