Skip to content

fs: fix glob case-sensitivity inconsistencies#63446

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

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

Conversation

@louiellan
Copy link
Copy Markdown

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 which shouldn't be on Windows and macOS,
  2. any casing difference in matched list not to be filtered out
  3. not returning the true casing of a matched directory / file

Could be notable-change because i suspect since this bug has been out for a while, i expect that developers might had some sense that the exclude option has always been a case sensitive part of the fs.glob, regardless of the operating systems quirks on case-sensitivity file system

@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
Copy link
Copy Markdown
Author

louiellan commented May 20, 2026

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, with merely the presence of a glob character in pattern, the file gets excluded (case-insensitively)
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
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