diff --git a/index.js b/index.js index 91a863e..3a14a53 100644 --- a/index.js +++ b/index.js @@ -3,8 +3,12 @@ var path = require('path'); var isglob = require('is-glob'); var pathDirname = require('path-dirname'); +var isWin32 = require('os').platform() === 'win32'; module.exports = function globParent(str) { + // flip windows path separators + if (isWin32 && str.indexOf('/') < 0) str = str.split('\\').join('/'); + // special case for strings ending in enclosure containing path separator if (/[\{\[].*[\/]*.*[\}\]]$/.test(str)) str += '/'; diff --git a/test.js b/test.js index 92f194a..2b9f212 100644 --- a/test.js +++ b/test.js @@ -162,3 +162,11 @@ describe('glob2base test patterns', function() { assert.equal(gp('ooga/{booga,sooga}/**/dooga/{eooga,fooga}'), 'ooga'); }); }); + +if (require('os').platform() === 'win32') { + describe('technically invalid windows globs', function() { + it('should manage simple globs with backslash path separator', function() { + assert.equal(gp('C:\\path\\*.js'), 'C:/path') + }); + }); +}