2023-01-04 00:36:49 -06:00
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
|
|
2024-08-04 18:44:33 -05:00
|
|
|
|
namespace LANCommander.Server.Extensions
|
2023-01-04 00:36:49 -06:00
|
|
|
|
{
|
|
|
|
|
|
public static class StringExtensions
|
|
|
|
|
|
{
|
|
|
|
|
|
public static string SanitizeFilename(this string filename, string replacement = "")
|
|
|
|
|
|
{
|
|
|
|
|
|
var removeInvalidChars = new Regex($"[{Regex.Escape(new string(Path.GetInvalidFileNameChars()))}]", RegexOptions.Singleline | RegexOptions.Compiled | RegexOptions.CultureInvariant);
|
|
|
|
|
|
|
|
|
|
|
|
return removeInvalidChars.Replace(filename, replacement);
|
|
|
|
|
|
}
|
2023-01-09 01:35:08 -06:00
|
|
|
|
|
|
|
|
|
|
public static string ToPath(this string path)
|
|
|
|
|
|
{
|
|
|
|
|
|
return Path.Combine(path.Split("/"));
|
|
|
|
|
|
}
|
2023-01-04 00:36:49 -06:00
|
|
|
|
}
|
|
|
|
|
|
}
|