mirror of
https://github.com/photoprism/photoprism.git
synced 2026-01-23 02:24:24 +00:00
19 lines
372 B
Go
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()
|
|
}
|