mirror of
https://github.com/lidarr/lidarr.git
synced 2025-07-14 17:13:49 -07:00
removed comma from windows invalid path chars.
This commit is contained in:
parent
566e4eb1ce
commit
f162f164e7
5 changed files with 61 additions and 2 deletions
39
NzbDrone.Common/StringExtensions.cs
Normal file
39
NzbDrone.Common/StringExtensions.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System.Text.RegularExpressions;
|
||||
using System.Linq;
|
||||
|
||||
namespace NzbDrone.Common
|
||||
{
|
||||
public static class StringExtensions
|
||||
{
|
||||
public static string Inject(this string format, params object[] formattingArgs)
|
||||
{
|
||||
return string.Format(format, formattingArgs);
|
||||
}
|
||||
|
||||
public static string Inject(this string format, params string[] formattingArgs)
|
||||
{
|
||||
return string.Format(format, formattingArgs.Cast<object>());
|
||||
}
|
||||
|
||||
|
||||
private static readonly Regex InvalidCharRegex = new Regex(@"[^a-z0-9\s-]", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
private static readonly Regex CollapseSpace = new Regex(@"\s+", RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
public static string ToSlug(this string phrase)
|
||||
{
|
||||
phrase = phrase.RemoveAccent().ToLower();
|
||||
|
||||
phrase = InvalidCharRegex.Replace(phrase, string.Empty);
|
||||
phrase = CollapseSpace.Replace(phrase, " ").Trim();
|
||||
phrase = phrase.Replace(" ", "-");
|
||||
|
||||
return phrase;
|
||||
}
|
||||
|
||||
public static string RemoveAccent(this string txt)
|
||||
{
|
||||
var bytes = System.Text.Encoding.GetEncoding("Cyrillic").GetBytes(txt);
|
||||
return System.Text.Encoding.ASCII.GetString(bytes);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue