| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2479553 commit 6b577c8
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -442,7 +442,18 @@ class Glob { | |||
| 442 | 442 | const fromSymlink = pattern.symlinks.has(index); | |
| 443 | 443 | ||
| 444 | 444 | if (current === lazyMinimatch().GLOBSTAR) { | |
| 445 | - if (entry.name[0] === '.' || (this.#exclude && this.#exclude(this.#withFileTypes ? entry : entry.name))) { | ||
| 445 | + const isDot = entry.name[0] === '.'; | ||
| 446 | + const nextMatches = pattern.test(nextIndex, entry.name); | ||
| 447 | + | ||
| 448 | + let nextNonGlobIndex = nextIndex; | ||
| 449 | + while (pattern.at(nextNonGlobIndex) === lazyMinimatch().GLOBSTAR) { | ||
| 450 | + nextNonGlobIndex++; | ||
| 451 | + } | ||
| 452 | + | ||
| 453 | + const matchesDot = isDot && pattern.test(nextNonGlobIndex, entry.name); | ||
| 454 | + | ||
| 455 | + if ((isDot && !matchesDot) || | ||
| 456 | + (this.#exclude && this.#exclude(this.#withFileTypes ? entry : entry.name))) { | ||
| 446 | 457 | continue; | |
| 447 | 458 | } | |
| 448 | 459 | if (!fromSymlink && entry.isDirectory()) { | |
@@ -455,7 +466,6 @@ class Glob { | |||
| 455 | 466 | ||
| 456 | 467 | // Any pattern after ** is also a potential pattern | |
| 457 | 468 | // so we can already test it here | |
| 458 | - const nextMatches = pattern.test(nextIndex, entry.name); | ||
| 459 | 469 | if (nextMatches && nextIndex === last && !isLast) { | |
| 460 | 470 | // If next pattern is the last one, add to results | |
| 461 | 471 | this.#results.add(entryPath); | |
@@ -642,30 +652,36 @@ class Glob { | |||
| 642 | 652 | const fromSymlink = pattern.symlinks.has(index); | |
| 643 | 653 | ||
| 644 | 654 | if (current === lazyMinimatch().GLOBSTAR) { | |
| 645 | - if (entry.name[0] === '.' || (this.#exclude && this.#exclude(this.#withFileTypes ? entry : entry.name))) { | ||
| 655 | + const isDot = entry.name[0] === '.'; | ||
| 656 | + const nextMatches = pattern.test(nextIndex, entry.name); | ||
| 657 | + | ||
| 658 | + let nextNonGlobIndex = nextIndex; | ||
| 659 | + while (pattern.at(nextNonGlobIndex) === lazyMinimatch().GLOBSTAR) { | ||
| 660 | + nextNonGlobIndex++; | ||
| 661 | + } | ||
| 662 | + | ||
| 663 | + const matchesDot = isDot && pattern.test(nextNonGlobIndex, entry.name); | ||
| 664 | + | ||
| 665 | + if ((isDot && !matchesDot) || | ||
| 666 | + (this.#exclude && this.#exclude(this.#withFileTypes ? entry : entry.name))) { | ||
| 646 | 667 | continue; | |
| 647 | 668 | } | |
| 648 | 669 | if (!fromSymlink && entry.isDirectory()) { | |
| 649 | 670 | // If directory, add ** to its potential patterns | |
| 650 | 671 | subPatterns.add(index); | |
| 651 | 672 | } else if (!fromSymlink && index === last) { | |
| 652 | 673 | // If ** is last, add to results | |
| 653 | - if (!this.#results.has(entryPath)) { | ||
| 654 | - if (this.#results.add(entryPath)) { | ||
| 655 | - yield this.#withFileTypes ? entry : entryPath; | ||
| 656 | - } | ||
| 674 | + if (!this.#results.has(entryPath) && this.#results.add(entryPath)) { | ||
| 675 | + yield this.#withFileTypes ? entry : entryPath; | ||
| 657 | 676 | } | |
| 658 | 677 | } | |
| 659 | 678 | ||
| 660 | 679 | // Any pattern after ** is also a potential pattern | |
| 661 | 680 | // so we can already test it here | |
| 662 | - const nextMatches = pattern.test(nextIndex, entry.name); | ||
| 663 | 681 | if (nextMatches && nextIndex === last && !isLast) { | |
| 664 | 682 | // If next pattern is the last one, add to results | |
| 665 | - if (!this.#results.has(entryPath)) { | ||
| 666 | - if (this.#results.add(entryPath)) { | ||
| 667 | - yield this.#withFileTypes ? entry : entryPath; | ||
| 668 | - } | ||
| 683 | + if (!this.#results.has(entryPath) && this.#results.add(entryPath)) { | ||
| 684 | + yield this.#withFileTypes ? entry : entryPath; | ||
| 669 | 685 | } | |
| 670 | 686 | } else if (nextMatches && entry.isDirectory()) { | |
| 671 | 687 | // Pattern matched, meaning two patterns forward | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,6 +30,8 @@ async function setup() { | |||
| 30 | 30 | 'a/cb/e/f', | |
| 31 | 31 | 'a/x/.y/b', | |
| 32 | 32 | 'a/z/.y/b', | |
| 33 | + 'a/.b', | ||
| 34 | + 'a/b/.b', | ||
| 33 | 35 | ].map((f) => resolve(fixtureDir, f)); | |
| 34 | 36 | ||
| 35 | 37 | const symlinkTo = resolve(fixtureDir, 'a/symlink/a/b/c'); | |
@@ -188,6 +190,9 @@ const patterns = { | |||
| 188 | 190 | ], | |
| 189 | 191 | '*/*/*/f': ['a/bc/e/f', 'a/cb/e/f'], | |
| 190 | 192 | './**/f': ['a/bc/e/f', 'a/cb/e/f'], | |
| 193 | + '**/.b': ['a/.b', 'a/b/.b'], | ||
| 194 | + './**/.b': ['a/.b', 'a/b/.b'], | ||
| 195 | + 'a/**/.b': ['a/.b', 'a/b/.b'], | ||
| 191 | 196 | 'a/symlink/a/b/c/a/b/c/a/b/c//a/b/c////a/b/c/**/b/c/**': common.isWindows ? [] : [ | |
| 192 | 197 | 'a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c', | |
| 193 | 198 | 'a/symlink/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a/b/c/a', | |
| Back | FazBrowse Home | New Git URL |
0 commit comments