Fixed: Handle null IEnumerable field values in SchemaBuilder

pull/390/merge
Qstick 2 years ago
parent 6c35c3fc6f
commit 011fd57f7d

@ -226,7 +226,11 @@ namespace Prowlarr.Http.ClientSchema
{
return fieldValue =>
{
if (fieldValue is JsonElement e && e.ValueKind == JsonValueKind.Array)
if (fieldValue == null)
{
return Enumerable.Empty<int>();
}
else if (fieldValue is JsonElement e && e.ValueKind == JsonValueKind.Array)
{
return e.EnumerateArray().Select(s => s.GetInt32());
}
@ -240,13 +244,17 @@ namespace Prowlarr.Http.ClientSchema
{
return fieldValue =>
{
if (fieldValue is JsonElement e && e.ValueKind == JsonValueKind.Array)
if (fieldValue == null)
{
return Enumerable.Empty<string>();
}
else if (fieldValue is JsonElement e && e.ValueKind == JsonValueKind.Array)
{
return e.EnumerateArray().Select(s => s.GetString());
}
else
{
return fieldValue.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(p => p.Trim());
return fieldValue.ToString().Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => v.Trim());
}
};
}

Loading…
Cancel
Save