From 1f4c2ad946722977ed883bcac9187f847d02ad85 Mon Sep 17 00:00:00 2001 From: Leonardo Galli Date: Sat, 1 Jul 2017 11:01:48 +0200 Subject: [PATCH] Fixed: A as part of an acronym being removed from clean title. Fixes #1747 --- .../ParserTests/NormalizeTitleFixture.cs | 34 +++++++++++++++++++ src/NzbDrone.Core/Parser/Parser.cs | 2 +- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs b/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs index 6e2b01366..d846eeee4 100644 --- a/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs @@ -72,6 +72,40 @@ namespace NzbDrone.Core.Test.ParserTests } } + [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")] diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index 0688e59dc..0abd6ba3e 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -278,7 +278,7 @@ namespace NzbDrone.Core.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|_)(?