Skip to content

Matching failed when adding drive's name in Windows #447

@fky2015

Description

@fky2015

Environment

  • OS Version: Windows 11
  • Node.js Version: v22.3.0

Actual && Expected behavior

Question: How to match all the files (e.g. .jpg) in D:/?

For test cases 1 and 2: after adding D:, the matching failed.
For test cases 2 and 7: matching on another drive will success.
For test cases 2 and 4 (or 5 and 6): after adding photos/, the matching will success. (But why?)

It seems it's an unexpected behavior.

// npm install --save fast-glob mock-fs
const fg = require('fast-glob');
const mock = require('mock-fs');

mock({
    'D:/photos/image1.jpg': '',
    'E:/hello/world.txt':'',
    'index.js': '',
})

// 1. correct result: [ 'D:/photos/image1.jpg', 'D:/code/test-glob/index.js' ]
console.log(fg.globSync(['/**/*'], { absolute: true, }));

// 2. unexpected result: [ 'D:/index.js' ]
console.log(fg.globSync(['D:/**/*'], { absolute: true, }));

// 3. unexpected result: [ 'D:/index.js' ]
console.log(fg.globSync(['D:\/**/*'], { absolute: true, }));

// 4. correct result: [ 'D:/photos/**/*' ]
console.log(fg.globSync(['D:/photos/**/*'], { absolute: true, }));

// 5. unexpected result: [ 'D:/index.js' ]
console.log(fg.globSync([fg.convertPathToPattern('D:\\**\\*')], { absolute: true, }));

// 6. correct result: [ 'D:/photos/image1.jpg' ]
console.log(fg.globSync([fg.convertPathToPattern('D:\\photos\\**\\*')], { absolute: true, }));

// 7. correct result: [ 'E:/hello/world.txt' ]
console.log(fg.globSync(['E:/**/*'], { absolute: true, }));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions