From 4ce4efcc618283a8d01129b3af75e78287d7926f Mon Sep 17 00:00:00 2001 From: Ske Date: Fri, 18 Oct 2019 13:34:54 +0200 Subject: [PATCH] Fix importing brackets from Tupperbox. Closes #123 --- PluralKit.Core/DataFiles.cs | 4 ++-- PluralKit.Core/Utils.cs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/PluralKit.Core/DataFiles.cs b/PluralKit.Core/DataFiles.cs index 4af01299..8c839269 100644 --- a/PluralKit.Core/DataFiles.cs +++ b/PluralKit.Core/DataFiles.cs @@ -307,8 +307,8 @@ namespace PluralKit.Bot AvatarUrl = AvatarUrl, Birthday = Birthday, Description = Description, - Prefix = Brackets.FirstOrDefault(), - Suffix = Brackets.Skip(1).FirstOrDefault() // TODO: can Tupperbox members have no proxies at all? + Prefix = Brackets.FirstOrDefault().NullIfEmpty(), + Suffix = Brackets.Skip(1).FirstOrDefault().NullIfEmpty() // TODO: can Tupperbox members have no proxies at all? }; } } diff --git a/PluralKit.Core/Utils.cs b/PluralKit.Core/Utils.cs index 615a7eeb..b71c5b6a 100644 --- a/PluralKit.Core/Utils.cs +++ b/PluralKit.Core/Utils.cs @@ -246,6 +246,11 @@ namespace PluralKit yield break; } } + + public static string NullIfEmpty(this string input) + { + return input.Trim().Length == 0 ? null : input; + } } public static class Emojis {