From 7d30c7d1ea16298ebc89d85efbdc1393135bf11b Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 7 Mar 2021 16:53:56 -0800 Subject: [PATCH] Fixed: Parsing similar author names with common words at end (cherry picked from commit 0fe24539625f8397dfb63d4618611db99c3c137a) --- .../ParserTests/NormalizeTitleFixture.cs | 28 +++++++++++++++---- src/NzbDrone.Core/Parser/Parser.cs | 2 +- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs b/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs index e58ce4184..c21578e21 100644 --- a/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs +++ b/src/NzbDrone.Core.Test/ParserTests/NormalizeTitleFixture.cs @@ -35,16 +35,13 @@ public void should_remove_special_characters_and_casing(string dirty, string cle [TestCase("or")] [TestCase("an")] [TestCase("of")] - public void should_remove_common_words(string word) + public void should_remove_common_words_from_middle_of_title(string word) { var dirtyFormat = new[] { "word.{0}.word", "word {0} word", - "word-{0}-word", - "word.word.{0}", - "word-word-{0}", - "word-word {0}", + "word-{0}-word" }; foreach (var s in dirtyFormat) @@ -54,6 +51,27 @@ public void should_remove_common_words(string word) } } + [TestCase("the")] + [TestCase("and")] + [TestCase("or")] + [TestCase("an")] + [TestCase("of")] + public void should_not_remove_common_words_from_end_of_title(string word) + { + var dirtyFormat = new[] + { + "word.word.{0}", + "word-word-{0}", + "word-word {0}" + }; + + foreach (var s in dirtyFormat) + { + var dirty = string.Format(s, word); + dirty.CleanAuthorName().Should().Be("wordword" + word.ToLower()); + } + } + [Test] public void should_remove_a_from_middle_of_title() { diff --git a/src/NzbDrone.Core/Parser/Parser.cs b/src/NzbDrone.Core/Parser/Parser.cs index c3723dacb..7cbf6bf79 100644 --- a/src/NzbDrone.Core/Parser/Parser.cs +++ b/src/NzbDrone.Core/Parser/Parser.cs @@ -158,7 +158,7 @@ public static class Parser new Regex(@"^b00bs$", RegexOptions.Compiled | RegexOptions.IgnoreCase) }; - private static readonly RegexReplace NormalizeRegex = new RegexReplace(@"((?:\b|_)(?