jellyfin/MediaBrowser.Controller/Library/NameExtensions.cs

27 lines
658 B
C#
Raw Normal View History

#pragma warning disable CS1591
using System;
2018-12-27 16:27:57 -07:00
using System.Collections.Generic;
2020-03-24 08:12:06 -07:00
using System.Linq;
using Diacritics.Extensions;
2018-12-27 16:27:57 -07:00
namespace MediaBrowser.Controller.Library
{
public static class NameExtensions
{
public static IEnumerable<string> DistinctNames(this IEnumerable<string> names)
=> names.GroupBy(RemoveDiacritics, StringComparer.OrdinalIgnoreCase)
.Select(x => x.First());
2020-09-20 05:02:41 -07:00
private static string RemoveDiacritics(string? name)
2018-12-27 16:27:57 -07:00
{
if (name == null)
{
return string.Empty;
}
return name.RemoveDiacritics();
}
}
}