notification: B3 — Content-Type header + URL trim

Fixes flagged in spec review of 1ff0b2d: ntfy POSTs need explicit
Content-Type: text/plain (the spec calls for it; ntfy works without
but explicit beats inferred); trim trailing slashes from server URL
to avoid double-slash when operators paste 'https://ntfy.sh/'.
This commit is contained in:
2026-05-04 19:38:16 +01:00
parent 1ff0b2dc86
commit e6c5dea6bf
2 changed files with 15 additions and 7 deletions
+11 -6
View File
@@ -12,12 +12,13 @@ func TestNtfySendsHeadersAndBody(t *testing.T) {
t.Parallel()
var (
gotTitle string
gotPri string
gotTags string
gotClick string
gotAuth string
gotBody string
gotTitle string
gotPri string
gotTags string
gotClick string
gotAuth string
gotContentType string
gotBody string
)
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
@@ -26,6 +27,7 @@ func TestNtfySendsHeadersAndBody(t *testing.T) {
gotTags = r.Header.Get("Tags")
gotClick = r.Header.Get("Click")
gotAuth = r.Header.Get("Authorization")
gotContentType = r.Header.Get("Content-Type")
b, _ := io.ReadAll(r.Body)
gotBody = string(b)
w.WriteHeader(http.StatusOK)
@@ -73,6 +75,9 @@ func TestNtfySendsHeadersAndBody(t *testing.T) {
if want := "Bearer tk1"; gotAuth != want {
t.Errorf("Authorization: got %q want %q", gotAuth, want)
}
if gotContentType != "text/plain" {
t.Errorf("Content-Type: got %q want %q", gotContentType, "text/plain")
}
if gotBody != "errors found" {
t.Errorf("body: got %q want %q", gotBody, "errors found")
}