Skip to content

Commit

Permalink
notify/webhook: trim space from url_file content
Browse files Browse the repository at this point in the history
Signed-off-by: Davide Bizzarri <[email protected]>
  • Loading branch information
b1zzu committed May 16, 2023
1 parent 93797c3 commit 140c3d6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion notify/webhook/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"io"
"net/http"
"os"
"strings"

"github.com/go-kit/log"
"github.com/go-kit/log/level"
Expand Down Expand Up @@ -110,7 +111,7 @@ func (n *Notifier) Notify(ctx context.Context, alerts ...*types.Alert) (bool, er
if err != nil {
return false, fmt.Errorf("read url_file: %w", err)
}
url = string(content)
url = strings.TrimSpace(string(content))
}

resp, err := notify.PostJSON(ctx, n.client, url, &buf)
Expand Down
2 changes: 1 addition & 1 deletion notify/webhook/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestWebhookReadingURLFromFile(t *testing.T) {

f, err := os.CreateTemp("", "webhook_url")
require.NoError(t, err, "creating temp file failed")
_, err = f.WriteString(u.String())
_, err = f.WriteString(u.String() + "\n")
require.NoError(t, err, "writing to temp file failed")

notifier, err := New(
Expand Down

0 comments on commit 140c3d6

Please sign in to comment.