From 6e77d8ac6328b4d26c7db73b26c7e269389fae70 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Fri, 18 Feb 2022 10:23:31 +0300 Subject: [PATCH] go.stargrave.org/feeder is another feeder --- doc/index.texi | 1 + rounds/redirectHTML.go | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/doc/index.texi b/doc/index.texi index 63c0254..ae61d9f 100644 --- a/doc/index.texi +++ b/doc/index.texi @@ -56,6 +56,7 @@ input dialogue is shown. It automatically loads initial form values from Permanent HTTP redirects are replaces with non-refreshing HTML page with the link, to make you explicitly allow that step. Temporary redirects are followed if it is neither @url{https://newsboat.org/, Newsboat} +nor @url{https://www.feeder.stargrave.org/, go.stargrave.org/feeder} user-agent, not image paths. @item diff --git a/rounds/redirectHTML.go b/rounds/redirectHTML.go index a5d4bd7..2e286d3 100644 --- a/rounds/redirectHTML.go +++ b/rounds/redirectHTML.go @@ -44,8 +44,14 @@ var imageExts = map[string]struct{}{ ".webp": {}, } -func isNewsboat(req *http.Request) bool { - return strings.Contains(req.Header.Get("User-Agent"), "newsboat/") +func isFeeder(req *http.Request) bool { + if strings.Contains(req.Header.Get("User-Agent"), "newsboat/") { + return true + } + if strings.Contains(req.Header.Get("User-Agent"), "go.stargrave.org-feeder/") { + return true + } + return false } func RoundRedirectHTML( @@ -62,7 +68,7 @@ func RoundRedirectHTML( case http.StatusMovedPermanently, http.StatusPermanentRedirect: redirType = "permanent" case http.StatusFound, http.StatusSeeOther, http.StatusTemporaryRedirect: - if isNewsboat(req) { + if isFeeder(req) { return true, nil } if _, ok := imageExts[filepath.Ext(req.URL.Path)]; ok { -- 2.44.0