Replace colons in titles with hyphens for file safety
parent
fead35e612
commit
c571058817
|
@ -7,9 +7,13 @@ namespace LANCommander.SDK.Extensions
|
|||
{
|
||||
public static string SanitizeFilename(this string filename, string replacement = "")
|
||||
{
|
||||
var colonInTitle = new Regex(@"(\w)(: )(\w)");
|
||||
var removeInvalidChars = new Regex($"[{Regex.Escape(new string(Path.GetInvalidFileNameChars()))}]", RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
||||
|
||||
return removeInvalidChars.Replace(filename, replacement);
|
||||
filename = colonInTitle.Replace(filename, "$1 - $3");
|
||||
filename = removeInvalidChars.Replace(filename, replacement);
|
||||
|
||||
return filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue