diff --git a/authentik.go b/authentik.go index 6a23e3e..c26dcb1 100644 --- a/authentik.go +++ b/authentik.go @@ -268,6 +268,10 @@ func normalisePublicPaths(paths []string) []string { out = append(out, path) } + if len(out) == 0 { + return nil + } + return out } diff --git a/modernization_test.go b/modernization_test.go index 612be35..7507313 100644 --- a/modernization_test.go +++ b/modernization_test.go @@ -231,6 +231,17 @@ func TestEngine_AuthentikConfig_Good_NormalisesPublicPaths(t *testing.T) { } } +func TestEngine_AuthentikConfig_Good_BlankPublicPathsRemainNil(t *testing.T) { + e, _ := api.New(api.WithAuthentik(api.AuthentikConfig{ + PublicPaths: []string{" ", "\t", ""}, + })) + + cfg := e.AuthentikConfig() + if cfg.PublicPaths != nil { + t.Fatalf("expected blank public paths to collapse to nil, got %v", cfg.PublicPaths) + } +} + func TestEngine_Register_Good_IgnoresNilGroups(t *testing.T) { e, _ := api.New()