1
0
Fork 0
mirror of https://github.com/Radarr/Radarr synced 2024-12-28 19:05:55 +00:00

Fixed: A as part of an acronym being removed from clean title. Fixes #1747

This commit is contained in:
Leonardo Galli 2017-07-01 11:01:48 +02:00
parent 7712aa62da
commit 1f4c2ad946
2 changed files with 35 additions and 1 deletions

View file

@ -72,6 +72,40 @@ public void should_remove_a_from_middle_of_title()
}
}
[Test]
public void should_not_remove_a_when_at_start_of_acronym()
{
var dirtyFormat = new[]
{
"word.{0}.N.K.L.E.word",
"word {0} N K L E word",
"word-{0}-N-K-L-E-word",
};
foreach (var s in dirtyFormat)
{
var dirty = string.Format(s, "a");
dirty.CleanSeriesTitle().Should().Be("wordankleword");
}
}
[Test]
public void should_not_remove_a_when_at_end_of_acronym()
{
var dirtyFormat = new[]
{
"word.N.K.L.E.{0}.word",
"word N K L E {0} word",
"word-N-K-L-E-{0}-word",
};
foreach (var s in dirtyFormat)
{
var dirty = string.Format(s, "a");
dirty.CleanSeriesTitle().Should().Be("wordnkleaword");
}
}
[TestCase("the")]
[TestCase("and")]
[TestCase("or")]

View file

@ -278,7 +278,7 @@ public static class Parser
//Regex to detect whether the title was reversed.
private static readonly Regex ReversedTitleRegex = new Regex(@"[-._ ](p027|p0801|\d{2}E\d{2}S)[-._ ]", RegexOptions.Compiled);
private static readonly Regex NormalizeRegex = new Regex(@"((?:\b|_)(?<!^)(a(?!$)|an|the|and|or|of)(?:\b|_))|\W|_",
private static readonly Regex NormalizeRegex = new Regex(@"((?:\b|_)(?<!^|\W\w\W)(a(?!$|\W\w\W)|an|the|and|or|of)(?:\b|_))|\W|_",
RegexOptions.IgnoreCase | RegexOptions.Compiled);
private static readonly Regex FileExtensionRegex = new Regex(@"\.[a-z0-9]{2,4}$",