diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 4cdc02123..5832ba9a4 100644
--- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -337,7 +337,7 @@
-
+
diff --git a/src/NzbDrone.Core.Test/OrganizerTests/CleanFilenameFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/CleanFilenameFixture.cs
new file mode 100644
index 000000000..144a38934
--- /dev/null
+++ b/src/NzbDrone.Core.Test/OrganizerTests/CleanFilenameFixture.cs
@@ -0,0 +1,30 @@
+using FluentAssertions;
+using NUnit.Framework;
+using NzbDrone.Core.Organizer;
+using NzbDrone.Core.Test.Framework;
+
+namespace NzbDrone.Core.Test.OrganizerTests
+{
+ [TestFixture]
+ public class CleanFilenameFixture : CoreTest
+ {
+ [TestCase("Law & Order: Criminal Intent - S10E07 - Icarus [HDTV-720p]", "Law & Order- Criminal Intent - S10E07 - Icarus [HDTV-720p]")]
+ public void should_replaace_invalid_characters(string name, string expectedName)
+ {
+ FileNameBuilder.CleanFileName(name).Should().Be(expectedName);
+ }
+
+ [TestCase(".hack s01e01", "hack s01e01")]
+ public void should_remove_periods_from_start(string name, string expectedName)
+ {
+ FileNameBuilder.CleanFileName(name).Should().Be(expectedName);
+ }
+
+ [TestCase(" Series Title - S01E01 - Episode Title", "Series Title - S01E01 - Episode Title")]
+ [TestCase("Series Title - S01E01 - Episode Title ", "Series Title - S01E01 - Episode Title")]
+ public void should_remove_spaces_from_start_and_end(string name, string expectedName)
+ {
+ FileNameBuilder.CleanFileName(name).Should().Be(expectedName);
+ }
+ }
+}
diff --git a/src/NzbDrone.Core.Test/OrganizerTests/CleanFixture.cs b/src/NzbDrone.Core.Test/OrganizerTests/CleanFixture.cs
deleted file mode 100644
index 9e8600104..000000000
--- a/src/NzbDrone.Core.Test/OrganizerTests/CleanFixture.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using FluentAssertions;
-using NUnit.Framework;
-using NzbDrone.Core.Organizer;
-using NzbDrone.Core.Test.Framework;
-
-namespace NzbDrone.Core.Test.OrganizerTests
-{
- [TestFixture]
- public class CleanFixture : CoreTest
- {
- [TestCase("Law & Order: Criminal Intent - S10E07 - Icarus [HDTV-720p]",
- "Law & Order- Criminal Intent - S10E07 - Icarus [HDTV-720p]")]
- public void CleanFileName(string name, string expectedName)
- {
- FileNameBuilder.CleanFileName(name).Should().Be(expectedName);
- }
-
- }
-}
\ No newline at end of file
diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs
index f4737bc37..3cec79b69 100644
--- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs
+++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs
@@ -274,7 +274,7 @@ public static string CleanFileName(string name, bool replace = true)
result = result.Replace(badCharacters[i], replace ? goodCharacters[i] : string.Empty);
}
- return result.Trim();
+ return result.TrimStart(' ', '.').TrimEnd(' ');
}
public static string CleanFolderName(string name)