diff --git a/lib/imgbundler/imgbundler.go b/lib/imgbundler/imgbundler.go index 5c6de7038..50e3b126b 100644 --- a/lib/imgbundler/imgbundler.go +++ b/lib/imgbundler/imgbundler.go @@ -23,6 +23,8 @@ import ( "oss.terrastruct.com/util-go/xmain" ) +var imgCache sync.Map + const maxImageSize int64 = 1 << 25 // 33_554_432 var imageRegex = regexp.MustCompile(`ab +`, url1, url2) + + ms := &xmain.State{ + Name: "test", + + Stdin: os.Stdin, + Stdout: os.Stdout, + Stderr: os.Stderr, + + Env: xos.NewEnv(os.Environ()), + } + ms.Log = cmdlog.NewTB(ms.Env, t) + + count := 0 + + httpClient.Transport = roundTripFunc(func(req *http.Request) *http.Response { + count++ + respRecorder := httptest.NewRecorder() + respRecorder.WriteString(`\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n`) + respRecorder.WriteHeader(200) + return respRecorder.Result() + }) + + out, err := BundleRemote(ctx, ms, []byte(sampleSVG)) + if err != nil { + t.Fatal(err) + } + tassert.Equal(t, 1, count) + if strings.Contains(string(out), url1) { + t.Fatal("links still exist") + } + tassert.Equal(t, 2, strings.Count(string(out), "image/svg+xml")) +}