Skip to content

fs: fix glob case-sensitivity inconsistencies#63446

Closed
louiellan wants to merge 1 commit into
nodejs:mainfrom
louiellan:fix-exclude-glob
Closed

fs: fix glob case-sensitivity inconsistencies#63446
louiellan wants to merge 1 commit into
nodejs:mainfrom
louiellan:fix-exclude-glob

Conversation

@louiellan

@louiellan louiellan commented May 20, 2026

Copy link
Copy Markdown
Contributor

Refs: #58991

fix matchers' nocaseMagicOnly option where it makes any non-magical/literal pattern case-sensitive which results to:

  1. making the exclude option case sensitive

  2. not returning the actual casing of a matched directory / file

not ideal for the case-insensitive nature of Windows and MacOS filesystems.

It would be a notable-change since developers may have been relying already on this behavior

@nodejs-github-bot nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels May 20, 2026
@louiellan

louiellan commented May 20, 2026

Copy link
Copy Markdown
Contributor Author

For additional info

with a directory structure:

a
   |---> index.txt
sample.js

sample.js

const fs = require('node:fs')

// test-1
let files = fs.globSync('a/index.TXT', { exclude: ['a/index.txt'] })
console.log(files)

// test-2
files = fs.globSync('a/index.TXT', { exclude: ['a/in*dex.txt'] })
console.log(files)

// test-3
files = fs.globSync('a/index.TXT', { exclude: ['a*/index.txt'] })
console.log(files)

In test-2, the presence of a glob character in pattern, the file gets excluded

with only a literal string, like those in test-1 and test-3 where the filename itself does not have a glob character, the file doesn't get excluded

the test-1 and test-3 should filter the file just like the test-2 as they're technically the same

where the `exclude` option is case sensitive but the `pattern` is a
case insensitive operation (on Windows and MacOS), thus results to
any casing difference in matched list not to be filtered out and does
not return the true casing of a matched directory / file

Signed-off-by: louiellan <louie.lou.llaneta@gmail.com>
@louiellan louiellan changed the title fs: fix glob case mismatch on Windows and MacOS fs: fix glob case-sensitivity inconsistencies May 20, 2026
@codecov

codecov Bot commented Jun 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.08%. Comparing base (4ee7567) to head (a1aa147).
⚠️ Report is 204 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #63446      +/-   ##
==========================================
+ Coverage   90.05%   90.08%   +0.03%     
==========================================
  Files         714      714              
  Lines      225876   225918      +42     
  Branches    42737    42745       +8     
==========================================
+ Hits       203408   203514     +106     
+ Misses      14244    14185      -59     
+ Partials     8224     8219       -5     
Files with missing lines Coverage Δ
lib/internal/fs/glob.js 91.48% <100.00%> (ø)

... and 35 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@louiellan

Copy link
Copy Markdown
Contributor Author

Fixing this bug alone could introduce confusion on glob's case sensitivity, especially in resolving canonical paths, I'm closing this PR in favor of the feature request #58991 (comment)

@louiellan louiellan closed this Jun 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants