-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.cs
More file actions
26 lines (23 loc) · 744 Bytes
/
Copy pathUtils.cs
File metadata and controls
26 lines (23 loc) · 744 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System.Text.RegularExpressions;
namespace WebhookReceiver;
public static class Utils
{
private static readonly Regex SanitizeExpression = new Regex("[^a-zA-Z0-9_.\\/\\-]+", RegexOptions.Compiled);
///<summary>Ersätter åäöéü mot aaoeu, mellanslag mot _ och tar bort övriga ogiltiga tecken.</summary>
public static string SanitizeFileName(this string itemName) {
itemName = itemName
.Replace('Å', 'A')
.Replace('Ä', 'A')
.Replace('Ö', 'O')
.Replace('É', 'E')
.Replace('Ü', 'U')
.Replace('å', 'a')
.Replace('ä', 'a')
.Replace('ö', 'o')
.Replace('é', 'e')
.Replace('ü', 'u')
.Replace(' ', '_')
.Replace('/', '_');
return SanitizeExpression.Replace(itemName, string.Empty);
}
}