chore: explicitly handle null description
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
|
namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
|
||||||
{
|
{
|
||||||
@@ -42,27 +43,25 @@ namespace Jellyfin.Plugin.TubeArchivistMetadata.Utilities
|
|||||||
/// <returns>A string with \n replaced by br tags.</returns>
|
/// <returns>A string with \n replaced by br tags.</returns>
|
||||||
public static string FormatDescription(string description)
|
public static string FormatDescription(string description)
|
||||||
{
|
{
|
||||||
try
|
if (description == null)
|
||||||
{
|
{
|
||||||
var maxLength = 500;
|
return "Description is null";
|
||||||
if (Plugin.Instance != null)
|
|
||||||
{
|
|
||||||
maxLength = Plugin.Instance.Configuration.MaxDescriptionLength;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (description.Length > maxLength)
|
|
||||||
{
|
|
||||||
description = description.Substring(0, maxLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
description = description.Replace("\n", "<br>", System.StringComparison.CurrentCulture);
|
|
||||||
|
|
||||||
return description;
|
|
||||||
}
|
}
|
||||||
catch (Exception)
|
|
||||||
|
var maxLength = 500;
|
||||||
|
if (Plugin.Instance != null)
|
||||||
{
|
{
|
||||||
return "Error getting description";
|
maxLength = Plugin.Instance.Configuration.MaxDescriptionLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (description.Length > maxLength)
|
||||||
|
{
|
||||||
|
description = description.Substring(0, maxLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
description = description.Replace("\n", "<br>", System.StringComparison.CurrentCulture);
|
||||||
|
|
||||||
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user