From 0c52646e7ac6fd3094c11e9a32c686d98cce27bd Mon Sep 17 00:00:00 2001 From: Eray Ates Date: Mon, 19 Sep 2022 13:42:04 +0200 Subject: [PATCH] fix: dangling spaces Signed-off-by: Eray Ates --- internal/route/rest/call.go | 7 ++++++- testdata/test.yaml | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/route/rest/call.go b/internal/route/rest/call.go index a080276..f6cd195 100644 --- a/internal/route/rest/call.go +++ b/internal/route/rest/call.go @@ -2,6 +2,7 @@ package rest import ( "context" + "regexp" "strings" "sync" "time" @@ -10,10 +11,14 @@ import ( "github.com/worldline-go/pong/internal/registry" ) +// regex for space +var rgxSpace = regexp.MustCompile(`\s+`) + func Request(ctx context.Context, cancel context.CancelFunc, wg *sync.WaitGroup, args *model.RestCheck, concurrent int, reg *registry.ClientReg) { // remove trailing spaces and multiple spaces urlX := strings.TrimSpace(args.URL) - urlX = strings.ReplaceAll(urlX, " ", " ") + + urlX = rgxSpace.ReplaceAllString(urlX, " ") urls := strings.Split(urlX, " ") timeout := time.Duration(args.Timeout) * time.Millisecond diff --git a/testdata/test.yaml b/testdata/test.yaml index 8df5c6e..0279a89 100644 --- a/testdata/test.yaml +++ b/testdata/test.yaml @@ -3,7 +3,7 @@ client: rest: - concurrent: 5 check: - - url: "https://api.punkapi.com/v2/beers/1 https://api.punkapi.com/v2/beers/2 https://api.punkapi.com/v2/beers/3 https://api.punkapi.com/v2/beers/4 https://api.punkapi.com/v2/beers/5 https://api.punkapi.com/v2/beers/6 https://api.punkapi.com/v2/beers/7 https://api.punkapi.com/v2/beers/8 https://api.punkapi.com/v2/beers/9 https://api.punkapi.com/v2/beers/10 https://api.punkapi.com/v2/beers/11 https://api.punkapi.com/v2/beers/12 https://api.punkapi.com/v2/beers/13 https://api.punkapi.com/v2/beers/14 https://api.punkapi.com/v2/beers/15 https://api.punkapi.com/v2/beers/16 https://api.punkapi.com/v2/beers/17 https://api.punkapi.com/v2/beers/18 https://api.punkapi.com/v2/beers/19 https://api.punkapi.com/v2/beers/20 https://api.punkapi.com/v2/beers/21 https://api.punkapi.com/v2/beers/22 https://api.punkapi.com/v2/beers/23 https://api.punkapi.com/v2/beers/24 https://api.punkapi.com/v2/beers/25 https://api.punkapi.com/v2/beers/26 https://api.punkapi.com/v2/beers/27 https://api.punkapi.com/v2/beers/28 https://api.punkapi.com/v2/beers/29 https://api.punkapi.com/v2/beers/30 https://api.punkapi.com/v2/beers/31 https://api.punkapi.com/v2/beers/32 https://api.punkapi.com/v2/beers/33 https://api.punkapi.com/v2/beers/34 https://api.punkapi.com/v2/beers/35 https://api.punkapi.com/v2/beers/36 https://api.punkapi.com/v2/beers/37 https://api.punkapi.com/v2/beers/38 https://api.punkapi.com/v2/beers/39 https://api.punkapi.com/v2/beers/40 https://api.punkapi.com/v2/beers/41 https://api.punkapi.com/v2/beers/42 https://api.punkapi.com/v2/beers/43 https://api.punkapi.com/v2/beers/44 https://api.punkapi.com/v2/beers/45 https://api.punkapi.com/v2/beers/46 https://api.punkapi.com/v2/beers/47 https://api.punkapi.com/v2/beers/48 https://api.punkapi.com/v2/beers/49 https://api.punkapi.com/v2/beers/50 https://api.punkapi.com/v2/beers/51 https://api.punkapi.com/v2/beers/52 https://api.punkapi.com/v2/beers/53 https://api.punkapi.com/v2/beers/54 https://api.punkapi.com/v2/beers/55 https://api.punkapi.com/v2/beers/56 https://api.punkapi.com/v2/beers/57 https://api.punkapi.com/v2/beers/58 https://api.punkapi.com/v2/beers/59 https://api.punkapi.com/v2/beers/60 https://api.punkapi.com/v2/beers/61 https://api.punkapi.com/v2/beers/62 https://api.punkapi.com/v2/beers/63 https://api.punkapi.com/v2/beers/64 https://api.punkapi.com/v2/beers/65 https://api.punkapi.com/v2/beers/66 https://api.punkapi.com/v2/beers/67 https://api.punkapi.com/v2/beers/68 https://api.punkapi.com/v2/beers/69 https://api.punkapi.com/v2/beers/70 https://api.punkapi.com/v2/beers/71 https://api.punkapi.com/v2/beers/72 https://api.punkapi.com/v2/beers/73 https://api.punkapi.com/v2/beers/74 https://api.punkapi.com/v2/beers/75 https://api.punkapi.com/v2/beers/76 https://api.punkapi.com/v2/beers/77 https://api.punkapi.com/v2/beers/78 https://api.punkapi.com/v2/beers/79 https://api.punkapi.com/v2/beers/80 https://api.punkapi.com/v2/beers/81 https://api.punkapi.com/v2/beers/82 https://api.punkapi.com/v2/beers/83 https://api.punkapi.com/v2/beers/84 https://api.punkapi.com/v2/beers/85 https://api.punkapi.com/v2/beers/86 https://api.punkapi.com/v2/beers/87 https://api.punkapi.com/v2/beers/88 https://api.punkapi.com/v2/beers/89 https://api.punkapi.com/v2/beers/90 https://api.punkapi.com/v2/beers/91 https://api.punkapi.com/v2/beers/92 https://api.punkapi.com/v2/beers/93 https://api.punkapi.com/v2/beers/94 https://api.punkapi.com/v2/beers/95 https://api.punkapi.com/v2/beers/96 https://api.punkapi.com/v2/beers/97 https://api.punkapi.com/v2/beers/98 https://api.punkapi.com/v2/beers/99" + - url: "https://api.punkapi.com/v2/beers/1 https://api.punkapi.com/v2/beers/2 https://api.punkapi.com/v2/beers/3 https://api.punkapi.com/v2/beers/4 https://api.punkapi.com/v2/beers/5 https://api.punkapi.com/v2/beers/6 https://api.punkapi.com/v2/beers/7 https://api.punkapi.com/v2/beers/8 https://api.punkapi.com/v2/beers/9 https://api.punkapi.com/v2/beers/10 https://api.punkapi.com/v2/beers/11 https://api.punkapi.com/v2/beers/12 https://api.punkapi.com/v2/beers/13 https://api.punkapi.com/v2/beers/14 https://api.punkapi.com/v2/beers/15 https://api.punkapi.com/v2/beers/16 https://api.punkapi.com/v2/beers/17 https://api.punkapi.com/v2/beers/18 https://api.punkapi.com/v2/beers/19 https://api.punkapi.com/v2/beers/20 https://api.punkapi.com/v2/beers/21 https://api.punkapi.com/v2/beers/22 https://api.punkapi.com/v2/beers/23 https://api.punkapi.com/v2/beers/24 https://api.punkapi.com/v2/beers/25 https://api.punkapi.com/v2/beers/26 https://api.punkapi.com/v2/beers/27 https://api.punkapi.com/v2/beers/28 https://api.punkapi.com/v2/beers/29 https://api.punkapi.com/v2/beers/30 https://api.punkapi.com/v2/beers/31 https://api.punkapi.com/v2/beers/32 https://api.punkapi.com/v2/beers/33 https://api.punkapi.com/v2/beers/34 https://api.punkapi.com/v2/beers/35 https://api.punkapi.com/v2/beers/36 https://api.punkapi.com/v2/beers/37 https://api.punkapi.com/v2/beers/38 https://api.punkapi.com/v2/beers/39 https://api.punkapi.com/v2/beers/40 https://api.punkapi.com/v2/beers/41 https://api.punkapi.com/v2/beers/42 https://api.punkapi.com/v2/beers/43 https://api.punkapi.com/v2/beers/44 https://api.punkapi.com/v2/beers/45 https://api.punkapi.com/v2/beers/46 https://api.punkapi.com/v2/beers/47 https://api.punkapi.com/v2/beers/48 https://api.punkapi.com/v2/beers/49 https://api.punkapi.com/v2/beers/50 https://api.punkapi.com/v2/beers/51 https://api.punkapi.com/v2/beers/52 https://api.punkapi.com/v2/beers/53 https://api.punkapi.com/v2/beers/54 https://api.punkapi.com/v2/beers/55 https://api.punkapi.com/v2/beers/56 https://api.punkapi.com/v2/beers/57 https://api.punkapi.com/v2/beers/58 https://api.punkapi.com/v2/beers/59 https://api.punkapi.com/v2/beers/60 https://api.punkapi.com/v2/beers/61 https://api.punkapi.com/v2/beers/62 https://api.punkapi.com/v2/beers/63 https://api.punkapi.com/v2/beers/64 https://api.punkapi.com/v2/beers/65 https://api.punkapi.com/v2/beers/66 https://api.punkapi.com/v2/beers/67 https://api.punkapi.com/v2/beers/68 https://api.punkapi.com/v2/beers/69 https://api.punkapi.com/v2/beers/70 https://api.punkapi.com/v2/beers/71 https://api.punkapi.com/v2/beers/72 https://api.punkapi.com/v2/beers/73 https://api.punkapi.com/v2/beers/74 https://api.punkapi.com/v2/beers/75 https://api.punkapi.com/v2/beers/76 https://api.punkapi.com/v2/beers/77 https://api.punkapi.com/v2/beers/78 https://api.punkapi.com/v2/beers/79 https://api.punkapi.com/v2/beers/80 https://api.punkapi.com/v2/beers/81 https://api.punkapi.com/v2/beers/82 https://api.punkapi.com/v2/beers/83 https://api.punkapi.com/v2/beers/84 https://api.punkapi.com/v2/beers/85 https://api.punkapi.com/v2/beers/86 https://api.punkapi.com/v2/beers/87 https://api.punkapi.com/v2/beers/88 https://api.punkapi.com/v2/beers/89 https://api.punkapi.com/v2/beers/90 https://api.punkapi.com/v2/beers/91 https://api.punkapi.com/v2/beers/92 https://api.punkapi.com/v2/beers/93 https://api.punkapi.com/v2/beers/94 https://api.punkapi.com/v2/beers/95 https://api.punkapi.com/v2/beers/96 https://api.punkapi.com/v2/beers/97 https://api.punkapi.com/v2/beers/98 https://api.punkapi.com/v2/beers/99" # timeout: 1000 status: 200 - url: "https://api.punkapi.com/v2/beers/you-wont-find-me"