From: Sergey Matveev Date: Tue, 7 Sep 2021 11:34:25 +0000 (+0300) Subject: More reliable Habr hack X-Git-Tag: v0.1.0~84 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=4a08befbafd49a1471ab629de4ab58621c702f32;p=tofuproxy.git More reliable Habr hack --- 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 }