From 2346dbaf8747da04ad033794a712e778d4d20bb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=A0Ilya=20Atamas?= Date: Tue, 23 Apr 2019 21:56:46 +0300 Subject: [PATCH] fix: temporarily disable tarballs caching to prevent yarn error --- proxy/cache.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/proxy/cache.go b/proxy/cache.go index 19235c2..8fccc2e 100644 --- a/proxy/cache.go +++ b/proxy/cache.go @@ -5,7 +5,6 @@ import ( "io/ioutil" "log" "net/http" - "regexp" "strings" ) @@ -36,7 +35,6 @@ func (proxy Proxy) GetCachedPath(options Options, path string, request *http.Req if err != nil { return nil, err } - defer res.Body.Close() if res.Header.Get("Content-Encoding") == "gzip" { zr, err := gzip.NewReader(res.Body) @@ -47,14 +45,17 @@ func (proxy Proxy) GetCachedPath(options Options, path string, request *http.Req res.Body = zr } + defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { return nil, err } - // TODO: avoid calling MustCompile every time - // find "dist": "https?://.*/ and replace to "dist": "{localurl}/ - pkg = regexp.MustCompile(`(?U)"tarball":"https?://.*/`).ReplaceAllString(string(body), `"dist": "http://localhost:8080/`) + pkg = string(body) + + // // TODO: avoid calling MustCompile every time + // // find "dist": "https?://.*/ and replace to "dist": "{localurl}/ + // pkg = regexp.MustCompile(`(?U)"tarball":"https?://.*/`).ReplaceAllString(string(body), `"dist": "http://localhost:8080/`) // save to redis err = proxy.Database.Set(key, pkg, options.DatabaseExpiration)