Skip to content

Commit

Permalink
Fixed the regex to properly handle different directory patterns passe…
Browse files Browse the repository at this point in the history
…d into the create directory
  • Loading branch information
niemyjski committed Sep 27, 2024
1 parent 8d70f0a commit 990b9c1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ private SearchCriteria GetRequestCriteria(string searchPattern)
string prefix;
Regex patternRegex;

// NOTE: Prefix has to be a directory path, so if we do have a wildcard it needs to be part of the pattern.
if (hasWildcard)
{
patternRegex = new Regex($"^{Regex.Escape(normalizedSearchPattern).Replace("\\*", ".*?")}$");
Expand All @@ -533,7 +534,7 @@ private SearchCriteria GetRequestCriteria(string searchPattern)
}
else
{
patternRegex = new Regex($"^{normalizedSearchPattern}$");
patternRegex = new Regex($"^{Regex.Escape(normalizedSearchPattern)}.*?$");
int slashPos = normalizedSearchPattern.LastIndexOf('/');
prefix = slashPos >= 0 ? normalizedSearchPattern[..slashPos] : String.Empty;
}
Expand Down

0 comments on commit 990b9c1

Please sign in to comment.