diff --git a/Elwig/Helpers/Utils.cs b/Elwig/Helpers/Utils.cs index 0c4adb6..6e3d339 100644 --- a/Elwig/Helpers/Utils.cs +++ b/Elwig/Helpers/Utils.cs @@ -348,7 +348,7 @@ namespace Elwig.Helpers { } public static (string, string?) SplitName(string fullName, string? familyName) { - if (familyName == null || familyName == "") return (fullName, null); + if (string.IsNullOrWhiteSpace(familyName)) return (fullName, null); var p0 = fullName.IndexOf(familyName, StringComparison.CurrentCultureIgnoreCase); if (p0 == -1) return (fullName, null); var p1 = fullName.IndexOf(" und "); @@ -362,8 +362,10 @@ namespace Elwig.Helpers { var p3 = fullName.LastIndexOf(' ', p2 - 1); return (fullName[0..p3], fullName[(p3 + 1)..^0]); } - } else { + } else if (p0 + familyName.Length >= fullName.Length || fullName[p0 + familyName.Length] == ' ') { return (familyName, fullName.Replace(familyName, "").Replace(" ", " ").Trim()); + } else { + return (fullName, null); } }