diff --git a/src/NzbDrone.Core.Test/Datastore/Migration/026_add_custom_formatsFixture.cs b/src/NzbDrone.Core.Test/Datastore/Migration/026_add_custom_formatsFixture.cs index 6bbd682ed..134c6ffc3 100644 --- a/src/NzbDrone.Core.Test/Datastore/Migration/026_add_custom_formatsFixture.cs +++ b/src/NzbDrone.Core.Test/Datastore/Migration/026_add_custom_formatsFixture.cs @@ -360,6 +360,68 @@ namespace NzbDrone.Core.Test.Datastore.Migration customFormats.First().FormatItems.First().Score.Should().Be(0); } + [Test] + public void should_migrate_case_sensitive_regex() + { + var db = WithMigrationTestDb(c => + { + c.Insert.IntoTable("ReleaseProfiles").Row(new + { + 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 + { + 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"); + } + [Test] public void should_migrate_naming_configs() { diff --git a/src/NzbDrone.Core/Datastore/Migration/026_add_custom_formats.cs b/src/NzbDrone.Core/Datastore/Migration/026_add_custom_formats.cs index 48970be09..1bde2abbf 100644 --- a/src/NzbDrone.Core/Datastore/Migration/026_add_custom_formats.cs +++ b/src/NzbDrone.Core/Datastore/Migration/026_add_custom_formats.cs @@ -148,7 +148,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