diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-12-09 08:00:52 -0600 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2021-12-09 08:00:52 -0600 |
| commit | 2262e842f42ccef7f557cee4f7e05c9adf15b739 (patch) | |
| tree | 216be0fbdfdab5728cfcd14101cb85de39a4c3f1 /src | |
| parent | 2d466b7b397ea22502893d2e053c74d2b91a6ef6 (diff) | |
| download | slskd-2262e842f42ccef7f557cee4f7e05c9adf15b739.tar.gz | |
simplify logic
Diffstat (limited to 'src')
| -rw-r--r-- | src/slskd/Common/Extensions.cs | 2 | ||||
| -rw-r--r-- | src/slskd/Common/Redactor.cs | 14 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/slskd/Common/Extensions.cs b/src/slskd/Common/Extensions.cs index be5bcf16..0f3f8362 100644 --- a/src/slskd/Common/Extensions.cs +++ b/src/slskd/Common/Extensions.cs @@ -318,7 +318,7 @@ namespace slskd public static Options Redact(this Options options) { var redacted = options.ToJson().FromJson<Options>(); - Redactor.Redact(redacted); + Redactor.Redact(redacted, redactWith: "*****"); return redacted; } diff --git a/src/slskd/Common/Redactor.cs b/src/slskd/Common/Redactor.cs index c695593b..b2069b12 100644 --- a/src/slskd/Common/Redactor.cs +++ b/src/slskd/Common/Redactor.cs @@ -44,18 +44,20 @@ namespace slskd return; } - var props = target.GetType().GetProperties(); - - foreach (var prop in props) + foreach (var prop in target.GetType().GetProperties()) { var value = prop.GetValue(target); - if (prop.GetCustomAttributes().Any(attr => attr.GetType() == typeof(SecretAttribute)) && prop.PropertyType == typeof(string) && value != null) + if (value == null) { - prop.SetValue(target, redactWith); + continue; } - if (value != null) + if (prop.GetCustomAttributes().Any(attr => attr.GetType() == typeof(SecretAttribute)) && prop.PropertyType == typeof(string)) + { + prop.SetValue(target, redactWith); + } + else { if (value.GetType().IsAssignableTo(typeof(IEnumerable))) { |
