1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00

Limit replacement of colons

This commit is contained in:
Mark McDowall 2019-03-05 18:08:34 -08:00
parent 7b5e8646eb
commit de7e805718
4 changed files with 12 additions and 3 deletions

View File

@ -52,6 +52,7 @@ public void Setup()
[TestCase("CSI: Crime Scene Investigation", "CSI - Crime Scene Investigation")]
[TestCase("Code:Breaker", "Code-Breaker")]
[TestCase("Back Slash\\", "Back Slash+")]
[TestCase("Forward Slash\\", "Forward Slash+")]
[TestCase("Greater Than>", "Greater Than")]

View File

@ -301,6 +301,12 @@ public static string CleanFileName(string name, bool replace = true)
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
string[] goodCharacters = { "+", "+", "", "", "!", "-", "-", "", "" };
// Replace a colon followed by a space with space dash space for a better appearance
if (replace)
{
result = result.Replace(": ", " - ");
}
for (int i = 0; i < badCharacters.Length; i++)
{
result = result.Replace(badCharacters[i], replace ? goodCharacters[i] : string.Empty);

View File

@ -2,10 +2,12 @@
{
public sealed class CaseInsensitiveTermMatcher : ITermMatcher
{
private readonly string _originalTerm;
private readonly string _term;
public CaseInsensitiveTermMatcher(string term)
{
_originalTerm = term;
_term = term.ToLowerInvariant();
}
@ -18,7 +20,7 @@ public string MatchingTerm(string value)
{
if (value.ToLowerInvariant().Contains(_term))
{
return _term;
return _originalTerm;
}
return null;