Skip to content

Commit

Permalink
allow feed suffix and feed header
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Mar 12, 2022
1 parent 3ce0c67 commit 5210572
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions routers/web/feed/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,13 @@ func feedActionsToFeedItems(ctx *context.Context, actions models.ActionList) (it

// GetFeedType return altered name and feed type, if type is empty it's no feed.
func GetFeedType(name string, req *http.Request) (string, string) {
if strings.Contains(req.Header.Get("Accept"), "application/rss+xml") {
return name, "rss"
}

if strings.Contains(req.Header.Get("Accept"), "application/atom+xml") {
return name, "atom"
}

if strings.HasSuffix(name, ".rss") {
if strings.HasSuffix(name, ".rss") ||
strings.Contains(req.Header.Get("Accept"), "application/rss+xml") {
return strings.TrimSuffix(name, ".rss"), "rss"
}

if strings.HasSuffix(name, ".atom") {
if strings.HasSuffix(name, ".atom") ||
strings.Contains(req.Header.Get("Accept"), "application/atom+xml") {
return strings.TrimSuffix(name, ".atom"), "atom"
}

Expand Down

0 comments on commit 5210572

Please sign in to comment.