Limit replacement of colons
This commit is contained in:
parent
7b5e8646eb
commit
de7e805718
|
@ -52,6 +52,7 @@ namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
|
||||||
|
|
||||||
|
|
||||||
[TestCase("CSI: Crime Scene Investigation", "CSI - Crime Scene Investigation")]
|
[TestCase("CSI: Crime Scene Investigation", "CSI - Crime Scene Investigation")]
|
||||||
|
[TestCase("Code:Breaker", "Code-Breaker")]
|
||||||
[TestCase("Back Slash\\", "Back Slash+")]
|
[TestCase("Back Slash\\", "Back Slash+")]
|
||||||
[TestCase("Forward Slash\\", "Forward Slash+")]
|
[TestCase("Forward Slash\\", "Forward Slash+")]
|
||||||
[TestCase("Greater Than>", "Greater Than")]
|
[TestCase("Greater Than>", "Greater Than")]
|
||||||
|
|
|
@ -301,6 +301,12 @@ namespace NzbDrone.Core.Organizer
|
||||||
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
|
string[] badCharacters = { "\\", "/", "<", ">", "?", "*", ":", "|", "\"" };
|
||||||
string[] goodCharacters = { "+", "+", "", "", "!", "-", "-", "", "" };
|
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++)
|
for (int i = 0; i < badCharacters.Length; i++)
|
||||||
{
|
{
|
||||||
result = result.Replace(badCharacters[i], replace ? goodCharacters[i] : string.Empty);
|
result = result.Replace(badCharacters[i], replace ? goodCharacters[i] : string.Empty);
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
{
|
{
|
||||||
public sealed class CaseInsensitiveTermMatcher : ITermMatcher
|
public sealed class CaseInsensitiveTermMatcher : ITermMatcher
|
||||||
{
|
{
|
||||||
|
private readonly string _originalTerm;
|
||||||
private readonly string _term;
|
private readonly string _term;
|
||||||
|
|
||||||
public CaseInsensitiveTermMatcher(string term)
|
public CaseInsensitiveTermMatcher(string term)
|
||||||
{
|
{
|
||||||
|
_originalTerm = term;
|
||||||
_term = term.ToLowerInvariant();
|
_term = term.ToLowerInvariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +20,7 @@
|
||||||
{
|
{
|
||||||
if (value.ToLowerInvariant().Contains(_term))
|
if (value.ToLowerInvariant().Contains(_term))
|
||||||
{
|
{
|
||||||
return _term;
|
return _originalTerm;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue