diff --git a/lib/glob-helpers.cjs b/lib/glob-helpers.cjs index 1a8074053..1145f793e 100644 --- a/lib/glob-helpers.cjs +++ b/lib/glob-helpers.cjs @@ -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); } diff --git a/test-tap/globs.js b/test-tap/globs.js index 164ea7a1b..73db32d47 100644 --- a/test-tap/globs.js +++ b/test-tap/globs.js @@ -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({