Skip to content

Commit

Permalink
fix #41724
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Jan 19, 2018
1 parent 3afc26e commit a3bede4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/vs/base/common/glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,12 @@ function parseRegExp(pattern: string): string {
}
}

// Tail: Add the slash we had split on if there is more to come and the next one is not a globstar
if (index < segments.length - 1 && segments[index + 1] !== GLOBSTAR) {
// Tail: Add the slash we had split on if there is more to come and the remaining pattern is not a globstar
// For example if pattern: some/**/*.js we want the "/" after some to be included in the RegEx to prevent
// a folder called "something" to match as well.
// However, if pattern: some/**, we tolerate that we also match on "something" because our globstar behaviour
// is to match 0-N segments.
if (index < segments.length - 1 && (segments[index + 1] !== GLOBSTAR || index + 2 < segments.length)) {
regEx += PATH_REGEX;
}

Expand Down
16 changes: 16 additions & 0 deletions src/vs/base/test/node/glob.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,22 @@ suite('Glob', () => {
assert(!glob.match(p, '/xpackage.json'));
});

test('issue 41724', function () {
let p = 'some/**/*.js';

assert(glob.match(p, 'some/foo.js'));
assert(glob.match(p, 'some/folder/foo.js'));
assert(!glob.match(p, 'something/foo.js'));
assert(!glob.match(p, 'something/folder/foo.js'));

p = 'some/**/*';

assert(glob.match(p, 'some/foo.js'));
assert(glob.match(p, 'some/folder/foo.js'));
assert(!glob.match(p, 'something/foo.js'));
assert(!glob.match(p, 'something/folder/foo.js'));
});

test('brace expansion', function () {
let p = '*.{html,js}';

Expand Down

0 comments on commit a3bede4

Please sign in to comment.