]> Sergey Matveev's repositories - tofuproxy.git/commitdiff
More reliable Habr hack
authorSergey Matveev <stargrave@stargrave.org>
Tue, 7 Sep 2021 11:34:25 +0000 (14:34 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 7 Sep 2021 11:34:25 +0000 (14:34 +0300)
main.go

diff --git a/main.go b/main.go
index 7fd892cd76244e889862fbbdef397fa8d7e80bcf..a48ec246ffc51f8eafe46741d4cc65e10fdd013f 100644 (file)
--- 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
        }