| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 9f9a960 commit 12f7fc0
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -936,15 +936,16 @@ function matchGlobPattern(path, pattern, windows = isWindows) { | |||
| 936 | 936 | validateString(path, 'path'); | |
| 937 | 937 | validateString(pattern, 'pattern'); | |
| 938 | 938 | ||
| 939 | + const cacheKey = `${windows ? 'win32' : 'posix'}:${pattern}`; | ||
| 939 | 940 | let matcher; | |
| 940 | - if (patternFnCache.has(pattern)) { | ||
| 941 | - matcher = patternFnCache.get(pattern); | ||
| 941 | + if (patternFnCache.has(cacheKey)) { | ||
| 942 | + matcher = patternFnCache.get(cacheKey); | ||
| 942 | 943 | } else { | |
| 943 | 944 | matcher = createMatcher(pattern, { | |
| 944 | 945 | kEmptyObject, | |
| 945 | 946 | platform: windows ? 'win32' : 'posix', | |
| 946 | 947 | }); | |
| 947 | - patternFnCache.set(pattern, matcher); | ||
| 948 | + patternFnCache.set(cacheKey, matcher); | ||
| 948 | 949 | ||
| 949 | 950 | if (patternFnCache.size >= kGlobPatternCacheLimit) { | |
| 950 | 951 | patternFnCache.delete(patternFnCache.keys().next().value); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,6 +31,9 @@ const globs = { | |||
| 31 | 31 | ], | |
| 32 | 32 | }; | |
| 33 | 33 | ||
| 34 | + // Matchers for the same pattern must not be shared across path platforms. | ||
| 35 | + assert.strictEqual(path.posix.matchesGlob('platform-cache/file', 'platform-cache/**'), true); | ||
| 36 | + assert.strictEqual(path.win32.matchesGlob('platform-cache\\file', 'platform-cache/**'), true); | ||
| 34 | 37 | ||
| 35 | 38 | for (const [platform, platformGlobs] of Object.entries(globs)) { | |
| 36 | 39 | for (const [pathStr, glob, expected] of platformGlobs) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments