mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 05:53:33 -07:00
Use Diacritical.Net library for NameFirstCharacter token
(cherry picked from commit 59ea524e0ce85333779f430b867e93aae366289f) Closes #4230
This commit is contained in:
parent
2e91a61ccf
commit
8df5a5011b
3 changed files with 5 additions and 2 deletions
|
@ -42,6 +42,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||||
[TestCase("¡Mucha Lucha!", "M", "¡Mucha Lucha!")]
|
[TestCase("¡Mucha Lucha!", "M", "¡Mucha Lucha!")]
|
||||||
[TestCase(".hack", "H", "hack")]
|
[TestCase(".hack", "H", "hack")]
|
||||||
[TestCase("Ütopya", "U", "Ütopya")]
|
[TestCase("Ütopya", "U", "Ütopya")]
|
||||||
|
[TestCase("Æon Flux", "A", "Æon Flux")]
|
||||||
public void should_get_expected_folder_name_back(string title, string parent, string child)
|
public void should_get_expected_folder_name_back(string title, string parent, string child)
|
||||||
{
|
{
|
||||||
_artist.Name = title;
|
_artist.Name = title;
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapper" Version="2.0.123" />
|
<PackageReference Include="Dapper" Version="2.0.123" />
|
||||||
|
<PackageReference Include="Diacritical.Net" Version="1.0.4" />
|
||||||
<PackageReference Include="System.Text.Json" Version="6.0.8" />
|
<PackageReference Include="System.Text.Json" Version="6.0.8" />
|
||||||
<PackageReference Include="System.Memory" Version="4.5.5" />
|
<PackageReference Include="System.Memory" Version="4.5.5" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.1" />
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using Diacritical;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NzbDrone.Common.Cache;
|
using NzbDrone.Common.Cache;
|
||||||
using NzbDrone.Common.Disk;
|
using NzbDrone.Common.Disk;
|
||||||
|
@ -268,13 +269,13 @@ namespace NzbDrone.Core.Organizer
|
||||||
{
|
{
|
||||||
if (char.IsLetterOrDigit(title[0]))
|
if (char.IsLetterOrDigit(title[0]))
|
||||||
{
|
{
|
||||||
return title.Substring(0, 1).ToUpper().RemoveAccent();
|
return title.Substring(0, 1).ToUpper().RemoveDiacritics()[0].ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try the second character if the first was non alphanumeric
|
// Try the second character if the first was non alphanumeric
|
||||||
if (char.IsLetterOrDigit(title[1]))
|
if (char.IsLetterOrDigit(title[1]))
|
||||||
{
|
{
|
||||||
return title.Substring(1, 1).ToUpper().RemoveAccent();
|
return title.Substring(1, 1).ToUpper().RemoveDiacritics()[0].ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default to "_" if no alphanumeric character can be found in the first 2 positions
|
// Default to "_" if no alphanumeric character can be found in the first 2 positions
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue