Skip to content

Commit

Permalink
fixed error, when company name is null
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrKnarz committed Apr 4, 2023
1 parent e23c933 commit 08edee2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Generic/CompanyCompanion/ViewModels/MergeCompanies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public MergeCompanies(CompanyCompanion plugin)
/// <param name="name">Name to clean.</param>
/// <param name="wordList">List of words to remove.</param>
/// <returns>Name with the words removed</returns>
private string RemoveWords(string name, List<string> wordList)
private static string RemoveWords(string name, IReadOnlyCollection<string> wordList)
{
return name != null
? string.Join(" ", name.Split().Where(w => !wordList.Contains(w.RemoveSpecialChars().Replace("-", ""), StringComparer.InvariantCultureIgnoreCase)))
Expand All @@ -75,6 +75,11 @@ private string RemoveWords(string name, List<string> wordList)
/// <returns>cleaned up name</returns>
private string CleanUpCompanyName(string name)
{
if (string.IsNullOrEmpty(name))
{
return name;
}

string newName = name;

if (newName.EndsWith(")"))
Expand Down Expand Up @@ -114,6 +119,7 @@ public void GetMergeList(bool cleanUpName = false, bool findSimilar = false)
try
{
List<MergeItem> companyList = API.Instance.Database.Companies
.Where(c => !string.IsNullOrEmpty(c.Name))
.Select(c => new MergeItem
{
Id = c.Id,
Expand Down

0 comments on commit 08edee2

Please sign in to comment.