Skip to content
This repository has been archived by the owner on Oct 2, 2021. It is now read-only.

Commit

Permalink
Fix #268 - Fix .* pattern in skipFiles glob
Browse files Browse the repository at this point in the history
  • Loading branch information
roblourens committed Jan 21, 2018
1 parent 5e2ce71 commit 0b79e7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,8 @@ export function pathToRegex(aPath: string, caseSensitive: boolean): string {

export function pathGlobToBlackboxedRegex(glob: string): string {
return escapeRegexSpecialChars(glob, '*')
.replace(/([^*]|^)\*([^*]|$)/g, '$1.*$2') // * -> .*
.replace(/\*\*(\\\/|\\\\)?/g, '(.*\\\/)?') // **/ -> (.*\/)?
.replace(/([^\.]|^)\*/g, '$1.*') // * -> .*

// Just to simplify
.replace(/\.\*\\\/\.\*/g, '.*') // .*\/.* -> .*
Expand Down
4 changes: 4 additions & 0 deletions test/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,10 @@ suite('Utils', () => {
// but not something that ends in foo.js
assert(!r.test('barfoo.js'));
});

test('.* in glob', () => {
testPathGlobToBlackboxedRegex('foo.*.bar', 'foo\\..*\\.bar');
});
});

suite('makeRegexNotMatchPath/makeRegexMatchPath', () => {
Expand Down

0 comments on commit 0b79e7c

Please sign in to comment.