From 4a08befbafd49a1471ab629de4ab58621c702f32 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Tue, 7 Sep 2021 14:34:25 +0300 Subject: [PATCH] More reliable Habr hack --- main.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 7fd892c..a48ec24 100644 --- a/main.go +++ b/main.go @@ -141,10 +141,8 @@ func roundTrip(w http.ResponseWriter, req *http.Request) { return } - if host == "habrastorage.org" && - strings.Contains(req.URL.Path, "/webt/") && - !strings.HasPrefix(req.URL.Path, "/webt/") { - req.URL.Path = req.URL.Path[strings.Index(req.URL.Path, "/webt/"):] + if host == "habrastorage.org" && strings.Contains(req.URL.Path, "r/w780q1") { + req.URL.Path = strings.Replace(req.URL.Path, "r/w780q1/", "", 1) http.Redirect(w, req, req.URL.String(), http.StatusFound) return } -- 2.44.0