Makes checks a little more robust

(cherry picked from commit ca75a25802)
This commit is contained in:
Sebastiaan Janssen
2019-07-24 11:32:18 +02:00
parent 361557dc39
commit 17527c99eb

View File

@@ -39,14 +39,23 @@ namespace Umbraco.Web.PropertyEditors
/// <inheritdoc />
public override object FromEditor(ContentPropertyData editorValue, object currentValue)
{
var value = editorValue?.Value?.ToString();
if (string.IsNullOrEmpty(value))
{
return null;
}
if (editorValue.Value is JArray json)
{
return json.Select(x => x.Value<string>());
}
else if ( editorValue.Value is string stringValue && !String.IsNullOrWhiteSpace(stringValue))
if (string.IsNullOrWhiteSpace(value) == false)
{
return stringValue.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
return value.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
}
return null;
}