Skip to content

Commit e775a78

Browse files
committed
strip leading ./ from ignore patterns
fix: #570
1 parent 7e927b2 commit e775a78

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/ignore.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,12 @@ export class Ignore implements IgnoreLike {
7676
if (!parsed || !globParts) {
7777
throw new Error('invalid pattern object')
7878
}
79+
// strip off leading ./ portions
80+
// https://github.com/isaacs/node-glob/issues/570
81+
while (parsed[0] === '.' && globParts[0] === '.') {
82+
parsed.shift()
83+
globParts.shift()
84+
}
7985
/* c8 ignore stop */
8086
const p = new Pattern(parsed, globParts, 0, platform)
8187
const m = new Minimatch(p.globString(), mmopts)

test/ignore.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type Case = [
2121
expect: string[],
2222
optOrCwd?: GlobOptions | string | undefined
2323
]
24+
2425
const cases: Case[] = [
2526
[
2627
'*',
@@ -336,6 +337,18 @@ const cases: Case[] = [
336337
(process.cwd() + '/a/x/**').split(sep).join('/'),
337338
j(['a/z/.y/b']),
338339
],
340+
[
341+
'./*',
342+
'{./,c}b',
343+
j(['abcdef', 'abcfed', 'bc', 'c', 'symlink', 'x', 'z']),
344+
'a',
345+
],
346+
[
347+
'./*',
348+
'./c/../b',
349+
j(['abcdef', 'abcfed', 'bc', 'c', 'cb', 'symlink', 'x', 'z']),
350+
'a',
351+
],
339352
]
340353

341354
for (const c of cases) {

0 commit comments

Comments
 (0)