diff --git a/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs b/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs index 6f595f9..1c1a28c 100644 --- a/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs +++ b/src/Foundatio.Storage.SshNet/Storage/SshNetFileStorage.cs @@ -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("\\*", ".*?")}$"); @@ -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; }