mirror of
https://github.com/jcreek/Creek.FileRepository.git
synced 2026-07-12 18:33:43 +00:00
refactor(*): Use more human readable regex for determining if there are any invalid characters in a string
This commit is contained in:
@@ -17,9 +17,9 @@ namespace Creek.FileRepository.Helpers
|
|||||||
/// <returns>Returns true if the filename contains invalid characters.</returns>
|
/// <returns>Returns true if the filename contains invalid characters.</returns>
|
||||||
public static bool IsInvalidFileName(this string filename)
|
public static bool IsInvalidFileName(this string filename)
|
||||||
{
|
{
|
||||||
char[] invalidCharacters = new char[] { '<', '>', ':', '\'', '/', '\\', '|', '?', '*' };
|
// Check for Windows characters explicitly to ensure the filename is valid for Linux and Windows
|
||||||
|
Regex regex = new Regex(@"[<>:'\/\\|\?\*]");
|
||||||
return Array.Exists(invalidCharacters, character => filename.Contains(character.ToString()));
|
return regex.IsMatch(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user