GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: key glob matcher cache by platform · nodejs/node@b250b40

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/fs
    • glob.js
  • test/parallel
    • test-path-glob.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/fs/glob.js‎

Copy file name to clipboardExpand all lines: lib/internal/fs/glob.js
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -936,15 +936,16 @@ function matchGlobPattern(path, pattern, windows = isWindows) {
936936
validateString(path, 'path');
937937
validateString(pattern, 'pattern');
938938

939+
const cacheKey = `${windows ? 'win32' : 'posix'}:${pattern}`;
939940
let matcher;
940-
if (patternFnCache.has(pattern)) {
941-
matcher = patternFnCache.get(pattern);
941+
if (patternFnCache.has(cacheKey)) {
942+
matcher = patternFnCache.get(cacheKey);
942943
} else {
943944
matcher = createMatcher(pattern, {
944945
kEmptyObject,
945946
platform: windows ? 'win32' : 'posix',
946947
});
947-
patternFnCache.set(pattern, matcher);
948+
patternFnCache.set(cacheKey, matcher);
948949

949950
if (patternFnCache.size >= kGlobPatternCacheLimit) {
950951
patternFnCache.delete(patternFnCache.keys().next().value);
Collapse file

‎test/parallel/test-path-glob.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-path-glob.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const globs = {
3131
],
3232
};
3333

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);
3437

3538
for (const [platform, platformGlobs] of Object.entries(globs)) {
3639
for (const [pathStr, glob, expected] of platformGlobs) {

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.