Skip to content

Commit 2346dba

Browse files
committed
fix: temporarily disable tarballs caching to prevent yarn error
1 parent 588ec83 commit 2346dba

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

proxy/cache.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"io/ioutil"
66
"log"
77
"net/http"
8-
"regexp"
98
"strings"
109
)
1110

@@ -36,7 +35,6 @@ func (proxy Proxy) GetCachedPath(options Options, path string, request *http.Req
3635
if err != nil {
3736
return nil, err
3837
}
39-
defer res.Body.Close()
4038

4139
if res.Header.Get("Content-Encoding") == "gzip" {
4240
zr, err := gzip.NewReader(res.Body)
@@ -47,14 +45,17 @@ func (proxy Proxy) GetCachedPath(options Options, path string, request *http.Req
4745
res.Body = zr
4846
}
4947

48+
defer res.Body.Close()
5049
body, err := ioutil.ReadAll(res.Body)
5150
if err != nil {
5251
return nil, err
5352
}
5453

55-
// TODO: avoid calling MustCompile every time
56-
// find "dist": "https?://.*/ and replace to "dist": "{localurl}/
57-
pkg = regexp.MustCompile(`(?U)"tarball":"https?://.*/`).ReplaceAllString(string(body), `"dist": "http://localhost:8080/`)
54+
pkg = string(body)
55+
56+
// // TODO: avoid calling MustCompile every time
57+
// // find "dist": "https?://.*/ and replace to "dist": "{localurl}/
58+
// pkg = regexp.MustCompile(`(?U)"tarball":"https?://.*/`).ReplaceAllString(string(body), `"dist": "http://localhost:8080/`)
5859

5960
// save to redis
6061
err = proxy.Database.Set(key, pkg, options.DatabaseExpiration)

0 commit comments

Comments
 (0)