Skip to content

Commit

Permalink
Normalize glob patterns with trailing slashes
Browse files Browse the repository at this point in the history
Co-authored-by: Mark Wubben <mark@novemberborn.net>
  • Loading branch information
asaid-0 and novemberborn committed Sep 18, 2021
1 parent 66939e7 commit 6d9c4d7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/glob-helpers.cjs
Expand Up @@ -117,6 +117,10 @@ function normalizePattern(pattern) {
pattern = slash(pattern);
}

if (pattern.endsWith('/')) {
pattern = pattern.slice(0, -1);
}

if (pattern.startsWith('./')) {
return pattern.slice(2);
}
Expand Down
6 changes: 6 additions & 0 deletions test-tap/globs.js
Expand Up @@ -25,6 +25,12 @@ test('ignores relativeness in patterns', t => {
t.end();
});

test('ignores trailing slashes in (simple) patterns', t => {
const {filePatterns} = globs.normalizeGlobs({files: ['foo/', '!bar/', 'foo/{bar/,baz/}'], extensions: ['js'], providers: []});
t.same(filePatterns, ['foo', '!bar', 'foo/{bar/,baz/}']);
t.end();
});

test('isTest with defaults', t => {
const options = {
...globs.normalizeGlobs({
Expand Down

0 comments on commit 6d9c4d7

Please sign in to comment.