Skip to content

Drive letters on Windows return empty results #42

joewhite opened this Issue Apr 19, 2012 · 3 comments

3 participants


If I pass glob a search spec that includes a drive letter, it returns an empty array.

> process.cwd()
> glob.sync('/temp/*.txt')
[ '\\temp/1.txt' ]
> glob.sync('c:/temp/*.txt')

The two queries should return the same results (since C: is the current drive), but when I specify the full path including drive letter, glob returns nothing.

isaacs commented Apr 19, 2012

Confirmed. That is a bug.


The basic problem seems to be here:

read = prefix = path.join("/", prefix)

Essentially this turns it into /c:/temp/ which ain't right.

If I skip that for win32 (basically ignoring UNC, drives, etc.), and just use the else branch, it works fine. That said, I'm not really interested in all the other features (like mounting) that this might possibly break, so probably nothing patch quality...

This is somewhat related to issue 40.

Actually, there's also another issue. Using e.g. c:/* splits into:


Which of course has a different meaning on Windows. c:* means current directory, c:* means root of c:. This could affect any drive letter. I was able to work around this with basically this in the default case:

if (process.platform == "win32" && prefix.length === 2 && prefix[1] === ":")

Though I'm not sure if this is a complete fix either.


@amelon amelon pushed a commit to amelon/node-glob that referenced this issue Jun 20, 2012
@amelon-bflo amelon-bflo fix Issue #42 4bd657c
@isaacs isaacs added a commit that referenced this issue Oct 15, 2012
@amelon-bflo amelon-bflo fix Issue #42 a8b9394
isaacs commented Jan 23, 2013

Working on latest release.

@isaacs isaacs closed this Jan 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.