Skip to content

Commit e2932d3

Browse files
committed
fix: fix typo in tarball url replacing
1 parent 2346dba commit e2932d3

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

proxy/cache.go

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

@@ -53,9 +54,9 @@ func (proxy Proxy) GetCachedPath(options Options, path string, request *http.Req
5354

5455
pkg = string(body)
5556

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/`)
57+
// TODO: avoid calling MustCompile every time
58+
// find "dist": "https?://.*/ and replace to "dist": "{localurl}/
59+
pkg = regexp.MustCompile(`(?U)"tarball":"https?://.*/`).ReplaceAllString(string(body), `"tarball": "http://`+request.Host+"/")
5960

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

readme.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -153,12 +153,12 @@ Macbook Pro 15″ 2017, Intel Core i7-7700HQ. Note `GOMAXPROCS=1`.
153153
$ go-wrk -c 100 -d 10 http://localhost:8080/ascii
154154
Running 10s test @ http://localhost:8080/ascii
155155
100 goroutine(s) running concurrently
156-
84216 requests in 10.000196326s, 535.30MB read
157-
Requests/sec: 8421.43
158-
Transfer/sec: 53.53MB
159-
Avg Req Time: 11.874461ms
160-
Fastest Request: 2.213324ms
161-
Slowest Request: 745.874068ms
156+
120227 requests in 9.996788553s, 136.21MB read
157+
Requests/sec: 12026.56
158+
Transfer/sec: 13.63MB
159+
Avg Req Time: 8.314928ms
160+
Fastest Request: 1.157793ms
161+
Slowest Request: 782.917402ms
162162
Number of Errors: 0
163163
```
164164

0 commit comments

Comments
 (0)