8000 Don't prefix paths with drive letters with dots in `mkdirpSync`. [clo… · lodash/lodash@6b920fa · GitHub
[go: up one dir, main page]

Skip to content

Commit 6b920fa

Browse files
committed
Don't prefix paths with drive letters with dots in mkdirpSync. [closes #238]
Former-commit-id: dd0c8d7b1906210e5f26604d4149ba542727c78d
1 parent d1498bb commit 6b920fa

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

build/util.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
/** Load other modules */
1010
var _ = require('../lodash.js');
1111

12+
/** Used to indicate if running in Windows */
13+
var isWindows = process.platform == 'win32';
14+
1215
/*--------------------------------------------------------------------------*/
1316

1417
/**
@@ -17,7 +20,7 @@
1720
* @memberOf util.path
1821
* @type String
1922
*/
20-
var sep = path.sep || (process.platform == 'win32' ? '\\' : '/');
23+
var sep = path.sep || (isWindows ? '\\' : '/');
2124

2225
/**
2326
* The escaped path separator used for inclusion in RegExp strings.
@@ -27,6 +30,9 @@
2730
*/
2831
var sepEscaped = sep.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
2932

33+
/** Used to determine if a path is prefixed with a drive letter, dot, or slash */
34+
var rePrefixed = RegExp('^(?:' + (isWindows ? '[a-zA-Z]:|' : '') + '\\.?)' + sepEscaped);
35+
3036
/*--------------------------------------------------------------------------*/
3137

3238
/**
@@ -39,7 +45,7 @@
3945
*/
4046
function mkdirpSync(dirname, mode) {
4147
// ensure relative paths are prefixed with `./`
42-
if (!RegExp('^\\.?' + sepEscaped).test(dirname)) {
48+
if (!rePrefixed.test(dirname)) {
4349
dirname = '.' + sep + dirname;
4450
}
4551
dirname.split(sep).reduce(function(currPath, segment) {

0 commit comments

Comments
 (0)
0