Skip to content

Commit

Permalink
fix - reg - Fixed bugs regarding GetValuesString()
Browse files Browse the repository at this point in the history
---

As per the recent improvements concerning the argument parsing, one of them broke parsing the GetValuesString() function. We've finally fixed it to eliminate many bugs!

---

Type: fix
Breaking: False
Doc Required: False
Backport Required: False
Part: 1/1
  • Loading branch information
AptiviCEO committed Oct 2, 2024
1 parent 02bd877 commit f86e002
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions VisualCard/Parsers/VcardCommonTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
//

using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -473,10 +474,16 @@ internal static string GetValuesString(ArgumentInfo[] args, string @default, str
string finalSpecifierName = argSpecifier.EndsWith("=") ? argSpecifier.Substring(0, argSpecifier.Length - 1) : argSpecifier;
var argFromSpecifier = args.Where((arg) => arg.Key.Equals(finalSpecifierName, StringComparison.OrdinalIgnoreCase));

// Flatten the strings
var stringArrays = argFromSpecifier.Select((arg) => arg.AllValues);
List<string> flattened = [];
foreach (var stringArray in stringArrays)
flattened.AddRange(stringArray);

// Attempt to get the value from the key
string argString =
argFromSpecifier.Count() > 0 ?
string.Join(VcardConstants._valueDelimiter.ToString(), argFromSpecifier.Select((arg) => arg.AllValues)) :
flattened.Count() > 0 ?
string.Join(VcardConstants._valueDelimiter.ToString(), flattened) :
@default;
return argString;
}
Expand Down

0 comments on commit f86e002

Please sign in to comment.