Skip to content

Commit cc6968e

Browse files
authored
Fix handling of ignore patterns ending in * (#4552)
1 parent b2c03b4 commit cc6968e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/src/ignore.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,7 @@ _IgnoreParseResult _parseIgnorePattern(String pattern, bool ignoreCase) {
404404

405405
var current = first;
406406
String? peekChar() => current >= end ? null : pattern[current];
407+
String? previous() => current < 2 ? null : pattern[current - 2];
407408

408409
var expr = '';
409410

@@ -477,8 +478,8 @@ _IgnoreParseResult _parseIgnorePattern(String pattern, bool ignoreCase) {
477478
} else {
478479
expr += '.*';
479480
}
480-
} else if (peekChar() == '/' || peekChar() == null) {
481-
// /a/* should not match '/a/'
481+
} else if ((previous() == '/') && peekChar() == null) {
482+
// /a/* should not match '/a/', so we require at least one character
482483
expr += '[^/]+';
483484
} else {
484485
// Handle a single '*'

test/ignore_test.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,9 @@ final testData = [
823823
'src/file.txt': true,
824824
'folder/other.txt': true,
825825
'sub/folder/file.txt': true,
826+
'f': true,
827+
'f/a': true,
828+
'a/f': true,
826829
}),
827830
TestData.single('*f', {
828831
'file.txt': false,

0 commit comments

Comments
 (0)