photoprism/pkg/dsn/mask.go
Michael Mayer 06df64281d Config: Move database DSN-related functionality to "pkg/dsn" #47 #5285
Signed-off-by: Michael Mayer <michael@photoprism.app>
2025-11-03 13:40:34 +01:00

19 lines
372 B
Go

package dsn
// Mask hides the password portion of a DSN while leaving the rest untouched for logging/reporting.
func Mask(dsn string) string {
if dsn == "" {
return ""
}
// Parse database DSN.
d := Parse(dsn)
// Return original DSN if no password was found.
if d.Password == "" {
return dsn
}
// Return DSN with masked password.
return d.MaskPassword()
}