From 9ad44bdec052c143fb0d0affb91d8d4cfabedd79 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Mon, 28 Nov 2022 13:25:40 -0800 Subject: [PATCH] 2022-11-28 01:25:40PM --- lib/imgbundler/imgbundler.go | 27 ++++++++++++++++++--------- lib/imgbundler/imgbundler_test.go | 21 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/lib/imgbundler/imgbundler.go b/lib/imgbundler/imgbundler.go index 0cc88fc2b..5d705d60e 100644 --- a/lib/imgbundler/imgbundler.go +++ b/lib/imgbundler/imgbundler.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "net/http" + "net/url" "os" "regexp" "strings" @@ -15,8 +16,7 @@ import ( "oss.terrastruct.com/d2/lib/xmain" ) -var uriImgRe = regexp.MustCompile(``, href) + matches := imageRe.FindAllStringSubmatch(str, -1) + if len(matches) != 1 { + t.Fatalf("uri regex didn't match %s", str) + } + } +} + func TestInlineRemote(t *testing.T) { svgURL := "https://icons.terrastruct.com/essentials/004-picture.svg" pngURL := "https://cdn4.iconfinder.com/data/icons/smart-phones-technologies/512/android-phone.png"