Permalink
Browse files

cleanup filename shrinker

  • Loading branch information...
1 parent 5ee17ed commit f67c4cfe25097c0a7500ebf23eca107367b9b21d @lformella committed Dec 20, 2012
Showing with 3 additions and 7 deletions.
  1. +2 −2 Core.Test/Helper.cs
  2. +1 −5 Core/Helper.cs
View
@@ -31,11 +31,11 @@ public class Helper
[Test]
public void ShrinkFileName()
{
- const string fileName = "This_(is).-an_Evil)(File-_-name_[Test].txt";
+ const string fileName = "This_(is).-an_Evil) (F1le-_-name_[T3st].txt";
const long fileSize = 440044;
string result = Core.Helper.ShrinkFileName(fileName, fileSize);
- Assert.AreEqual("thisisanevilfilenametesttxt.440044/", result);
+ Assert.AreEqual("thisisanevilf1lenamet3sttxt.440044/", result);
}
}
}
View
@@ -110,11 +110,7 @@ public class Helper
/// <returns> </returns>
public static string ShrinkFileName(string aName, Int64 aSize)
{
- if (aName != null)
- {
- return Regex.Replace(aName, "(\\(|\\)|\\[|\\]|\\{|\\}|-|_|\\.)", "").ToLower() + "." + aSize + "/";
- }
- return "";
+ return aName != null ? Regex.Replace(aName.ToLower(), "[^a-z0-9]", "") + "." + aSize + "/" : "";
}
}
}

0 comments on commit f67c4cf

Please sign in to comment.