We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 298451b commit 81d757bCopy full SHA for 81d757b
types/host.go
@@ -96,3 +96,20 @@ func (h *Host) GetType() HostType {
96
}
97
return HttpType
98
99
+
100
+// SecureURL - returns a secure url that can be used in logs or alerts. It will hide the password if present.
101
+func (h *Host) SecureURL() string {
102
+ url := h.URL
103
+ if strings.HasPrefix(url, "mongodb://") {
104
+ if strings.Contains(url, "@") {
105
+ parts := strings.Split(url, "@")
106
+ creds := strings.Split(parts[0], ":")
107
+ if len(creds) == 3 {
108
+ creds[2] = "*****"
109
+ url = strings.Join(creds, ":") + "@" + parts[1]
110
+ }
111
112
+ return url
113
114
115
+}
0 commit comments