-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Move Path Sanitizer code to common .cs file * Update ThisAssembly.Resources to use common .cs file code * Test Sanitization Code * Fix more path name issues Closes #167 * Handle rare corner case ("/0/0/abc.csv")
- Loading branch information
1 parent
9589ddb
commit 92a5fdc
Showing
6 changed files
with
36 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Text.RegularExpressions; | ||
|
||
static class PathSanitizer | ||
{ | ||
static readonly Regex invalidCharsRegex = new(@"\W"); | ||
public static string Sanitize(string path, string parent) | ||
{ | ||
var partStr = invalidCharsRegex.Replace(path, "_"); | ||
if (char.IsDigit(partStr[0])) | ||
partStr = "_" + partStr; | ||
if (partStr == parent) | ||
partStr = "_" + partStr; | ||
return partStr; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters