Skip to content

Commit f09ab67

Browse files
ziqiqisaacs
authored andcommitted
fix: duplicated patterns in second phase preprocess loop
PR-URL: #235 Credit: @ziqiq Close: #235 Reviewed-by: @isaacs
1 parent d5ef89f commit f09ab67

File tree

3 files changed

+152
-3
lines changed

3 files changed

+152
-3
lines changed

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,9 +675,11 @@ export class Minimatch {
675675
globParts[j],
676676
!this.preserveMultipleSlashes
677677
)
678-
if (!matched) continue
679-
globParts[i] = matched
680-
globParts[j] = []
678+
if (matched) {
679+
globParts[i] = []
680+
globParts[j] = matched
681+
break
682+
}
681683
}
682684
}
683685
return globParts.filter(gs => gs.length)

tap-snapshots/test/optimization-level-2.ts.test.cjs

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4510,6 +4510,78 @@ Array [
45104510
]
45114511
`
45124512

4513+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > linux > {*,a,b} > defaults 1`] = `
4514+
Array [
4515+
Array [
4516+
"*",
4517+
],
4518+
]
4519+
`
4520+
4521+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > linux > {*,a,b} > multislash 1`] = `
4522+
Array [
4523+
Array [
4524+
"*",
4525+
],
4526+
]
4527+
`
4528+
4529+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > linux > {*,a,b} > no globstar 1`] = `
4530+
Array [
4531+
Array [
4532+
"*",
4533+
],
4534+
]
4535+
`
4536+
4537+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > linux > {a,*,b} > defaults 1`] = `
4538+
Array [
4539+
Array [
4540+
"*",
4541+
],
4542+
]
4543+
`
4544+
4545+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > linux > {a,*,b} > multislash 1`] = `
4546+
Array [
4547+
Array [
4548+
"*",
4549+
],
4550+
]
4551+
`
4552+
4553+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > linux > {a,*,b} > no globstar 1`] = `
4554+
Array [
4555+
Array [
4556+
"*",
4557+
],
4558+
]
4559+
`
4560+
4561+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > linux > {a,b,*} > defaults 1`] = `
4562+
Array [
4563+
Array [
4564+
"*",
4565+
],
4566+
]
4567+
`
4568+
4569+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > linux > {a,b,*} > multislash 1`] = `
4570+
Array [
4571+
Array [
4572+
"*",
4573+
],
4574+
]
4575+
`
4576+
4577+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > linux > {a,b,*} > no globstar 1`] = `
4578+
Array [
4579+
Array [
4580+
"*",
4581+
],
4582+
]
4583+
`
4584+
45134585
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > linux > {a/**/b,a/b} > defaults 1`] = `
45144586
Array [
45154587
Array [
@@ -5838,6 +5910,78 @@ Array [
58385910
]
58395911
`
58405912

5913+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > win32 > {*,a,b} > defaults 1`] = `
5914+
Array [
5915+
Array [
5916+
"*",
5917+
],
5918+
]
5919+
`
5920+
5921+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > win32 > {*,a,b} > multislash 1`] = `
5922+
Array [
5923+
Array [
5924+
"*",
5925+
],
5926+
]
5927+
`
5928+
5929+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > win32 > {*,a,b} > no globstar 1`] = `
5930+
Array [
5931+
Array [
5932+
"*",
5933+
],
5934+
]
5935+
`
5936+
5937+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > win32 > {a,*,b} > defaults 1`] = `
5938+
Array [
5939+
Array [
5940+
"*",
5941+
],
5942+
]
5943+
`
5944+
5945+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > win32 > {a,*,b} > multislash 1`] = `
5946+
Array [
5947+
Array [
5948+
"*",
5949+
],
5950+
]
5951+
`
5952+
5953+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > win32 > {a,*,b} > no globstar 1`] = `
5954+
Array [
5955+
Array [
5956+
"*",
5957+
],
5958+
]
5959+
`
5960+
5961+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > win32 > {a,b,*} > defaults 1`] = `
5962+
Array [
5963+
Array [
5964+
"*",
5965+
],
5966+
]
5967+
`
5968+
5969+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > win32 > {a,b,*} > multislash 1`] = `
5970+
Array [
5971+
Array [
5972+
"*",
5973+
],
5974+
]
5975+
`
5976+
5977+
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > win32 > {a,b,*} > no globstar 1`] = `
5978+
Array [
5979+
Array [
5980+
"*",
5981+
],
5982+
]
5983+
`
5984+
58415985
exports[`test/optimization-level-2.ts > TAP > explicit pattern coalescing and optimization > win32 > {a/**/b,a/b} > defaults 1`] = `
58425986
Array [
58435987
Array [

test/optimization-level-2.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ t.test('explicit pattern coalescing and optimization', t => {
6060
'./x/.././///.//./',
6161
'*/../**',
6262
'*/../**/?/*/[a-z]',
63+
'{*,a,b}',
64+
'{a,*,b}',
65+
'{a,b,*}',
6366
]
6467

6568
const exp = (p: string) => braceExpand(p).map(s => s.split('/'))

0 commit comments

Comments
 (0)