From 3ebfa76970a022f7a1a0303c415d74404234462c Mon Sep 17 00:00:00 2001 From: Laura Gomez Date: Mon, 16 Mar 2020 16:29:57 -0400 Subject: [PATCH] feat : Added ToPrivateString Method to convert password into special characters for privacy. --- ICD.Common.Utils/Extensions/UriExtensions.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ICD.Common.Utils/Extensions/UriExtensions.cs b/ICD.Common.Utils/Extensions/UriExtensions.cs index 976b1dd..503f295 100644 --- a/ICD.Common.Utils/Extensions/UriExtensions.cs +++ b/ICD.Common.Utils/Extensions/UriExtensions.cs @@ -46,5 +46,21 @@ namespace ICD.Common.Utils.Extensions return extends.ToString() == "http://localhost/"; } + + /// + /// Returns the string representation of the given URI, replacing the password with asterixes. + /// + /// + /// + public static string ToPrivateString([NotNull] this Uri extends) + { + if (extends == null) + throw new ArgumentNullException("extends"); + + IcdUriBuilder builder = new IcdUriBuilder(extends); + builder.Password = builder.Password == null ? null : StringUtils.PasswordFormat(builder.Password); + + return builder.ToString(); + } } }