Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit da5b657

Browse files
committed
Add GlobPath fix for direct partent folder
1 parent 2c8c9e2 commit da5b657

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/ServiceStack.Text/StringExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ public static bool GlobPath(this string filePath, string pattern)
11001100

11011101
if (dirPattern.IndexOf("**", StringComparison.Ordinal) >= 0)
11021102
{
1103-
if (!dirPart.StartsWith(dirPattern.LeftPart("**").TrimEnd('*')))
1103+
if (!filePath.StartsWith(dirPattern.LeftPart("**").TrimEnd('*', '/')))
11041104
return false;
11051105
}
11061106
else if (dirPattern.IndexOf('*') >= 0 || dirPattern.IndexOf('?') >= 0)

tests/ServiceStack.Text.Tests/GlobPathTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public void Does_validate_GlobPaths()
3939
Assert.That(!"dir/abc/file.txt".GlobPath("dir/a?/file.txt"));
4040
Assert.That("dir/abc/file.txt".GlobPath("dir/a?c/file.txt"));
4141

42+
Assert.That("dir/file.txt".GlobPath("dir/**/file.txt"));
43+
Assert.That(!"Dir/file.txt".GlobPath("dir/**/file.txt"));
4244
Assert.That("dir/a/file.txt".GlobPath("dir/**/file.txt"));
4345
Assert.That("dir/a/b/file.txt".GlobPath("dir/**/file.txt"));
4446
Assert.That("dir/a/b/c/d/e/file.txt".GlobPath("dir/**/file.txt"));

0 commit comments

Comments
 (0)