fs: fix glob case-sensitivity inconsistencies - #63446
Conversation
|
For additional info with a directory structure: 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 with only a literal string, like those in the |
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 <[email protected]>
75c8645 to
a1aa147
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. 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
🚀 New features to boost your workflow:
|
|
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) |
On case-insensitive platforms include patterns match entries regardless of case, but literal (non-magic) exclude patterns were matched case-sensitively because exclude matchers are created with nocaseMagicOnly. Exclusion is a pure string match with no filesystem lookups, so disable nocaseMagicOnly for exclude matchers. Fixes: nodejs#58991 Refs: nodejs#63446 Signed-off-by: Yusuke Hayashi <[email protected]>
On case-insensitive platforms include patterns match entries regardless of case, but literal (non-magic) exclude patterns were matched case-sensitively because exclude matchers are created with nocaseMagicOnly. Exclusion is a pure string match with no filesystem lookups, so disable nocaseMagicOnly for exclude matchers. Fixes: #58991 Refs: #63446 Signed-off-by: Yusuke Hayashi <[email protected]> PR-URL: #64817 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Stefan Stojanovic <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
On case-insensitive platforms include patterns match entries regardless of case, but literal (non-magic) exclude patterns were matched case-sensitively because exclude matchers are created with nocaseMagicOnly. Exclusion is a pure string match with no filesystem lookups, so disable nocaseMagicOnly for exclude matchers. Fixes: #58991 Refs: #63446 Signed-off-by: Yusuke Hayashi <[email protected]> PR-URL: #64817 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Stefan Stojanovic <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Refs: #58991
fix matchers'
nocaseMagicOnlyoption where it makes any non-magical/literal pattern case-sensitive which results to:making the
excludeoption case sensitivenot 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-changesince developers may have been relying already on this behavior