From 4751f57187f776dfbc2e38aee00171e7e3ea2e33 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Mon, 1 Dec 2025 23:59:17 +0000 Subject: [PATCH] test: Add edge case for capturePublicURLFromRequest nil inputs Tests the early return paths when router, request, or config are nil. --- internal/api/router_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/internal/api/router_test.go b/internal/api/router_test.go index 8c2cfb3..513a1c4 100644 --- a/internal/api/router_test.go +++ b/internal/api/router_test.go @@ -780,3 +780,27 @@ func TestCanCapturePublicURL_NilInputs(t *testing.T) { }) } } + +func TestCapturePublicURLFromRequest_NilInputs(t *testing.T) { + t.Parallel() + + t.Run("nil router", func(t *testing.T) { + var r *Router + req := httptest.NewRequest(http.MethodGet, "/", nil) + // Should not panic + r.capturePublicURLFromRequest(req) + }) + + t.Run("nil request", func(t *testing.T) { + r := &Router{config: &config.Config{}} + // Should not panic + r.capturePublicURLFromRequest(nil) + }) + + t.Run("nil config", func(t *testing.T) { + r := &Router{config: nil} + req := httptest.NewRequest(http.MethodGet, "/", nil) + // Should not panic + r.capturePublicURLFromRequest(req) + }) +}