diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/171_add_custom_formatsFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/171_add_custom_formatsFixture.cs index e9ee1a3be..6547f373d 100644 --- a/src/NzbDrone.Core.Test/Datastore/Migration/171_add_custom_formatsFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/Migration/171_add_custom_formatsFixture.cs @@ -482,6 +482,70 @@ namespace NzbDrone.Core.Test.Datastore.Migration customFormats.First().AnimeEpisodeFormat.Should().Be("{Series Title} - S{season:00}E{episode:00} - {Custom_Formats} {Quality Full}"); } + [Test] + public void should_migrate_case_sensitive_regex() + { + var db = WithMigrationTestDb(c => + { + c.Insert.IntoTable("ReleaseProfiles").Row(new + { + Name = "Profile", + Preferred = new[] + { + new + { + Key = "/somestring/", + Value = 2 + } + }.ToJson(), + Required = "[]", + Ignored = "[]", + Tags = "[]", + IncludePreferredWhenRenaming = true, + Enabled = true, + IndexerId = 0 + }); + }); + + var customFormats = db.Query("SELECT Id, Name, IncludeCustomFormatWhenRenaming, Specifications FROM CustomFormats"); + + customFormats.Should().HaveCount(1); + customFormats.First().Specifications.Should().HaveCount(1); + customFormats.First().Specifications.First().Body.Value.Should().Be("somestring"); + } + + [Test] + public void should_migrate_case_insensitive_regex() + { + var db = WithMigrationTestDb(c => + { + c.Insert.IntoTable("ReleaseProfiles").Row(new + { + Name = "Profile", + Preferred = new[] + { + new + { + Key = "/somestring/i", + Value = 2 + } + }.ToJson(), + Required = "[]", + Ignored = "[]", + Tags = "[]", + IncludePreferredWhenRenaming = true, + Enabled = true, + IndexerId = 0 + }); + }); + + var customFormats = db.Query("SELECT Id, Name, IncludeCustomFormatWhenRenaming, Specifications FROM CustomFormats"); + + customFormats.Should().HaveCount(1); + customFormats.First().Specifications.Should().HaveCount(1); + customFormats.First().Specifications.First().Body.Value.Should().Be("somestring"); + } + private class NamingConfig171 { public string StandardEpisodeFormat { get; set; } diff --git a/src/NzbDrone.Core/Datastore/Migration/171_add_custom_formats.cs b/src/NzbDrone.Core/Datastore/Migration/171_add_custom_formats.cs index 81fcd04b0..fa6ea1924 100644 --- a/src/NzbDrone.Core/Datastore/Migration/171_add_custom_formats.cs +++ b/src/NzbDrone.Core/Datastore/Migration/171_add_custom_formats.cs @@ -101,7 +101,10 @@ namespace NzbDrone.Core.Datastore.Migration foreach (var term in data) { - var regexTerm = term.Key.TrimStart('/').TrimEnd("/i"); + var regexTerm = term.Key + .TrimStart('/') + .TrimEnd('/') + .TrimEnd("/i"); // Validate Regex before creating a CF try