diff options
author | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2017-12-10 21:51:33 +0100 |
commit | 0469abd4a9c9270a1fdc962969e36e63699af8b4 (patch) | |
tree | f9864d4a4148621378958794cbbfdc2393733283 /node_modules/nanomatch/lib/utils.js | |
parent | 6947e79bbc258f7bc96af424ddb71a511f0c15a3 (diff) |
upgrade dependencies
Diffstat (limited to 'node_modules/nanomatch/lib/utils.js')
-rw-r--r-- | node_modules/nanomatch/lib/utils.js | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/node_modules/nanomatch/lib/utils.js b/node_modules/nanomatch/lib/utils.js index 962523be7..6fc434012 100644 --- a/node_modules/nanomatch/lib/utils.js +++ b/node_modules/nanomatch/lib/utils.js @@ -16,6 +16,14 @@ utils.typeOf = require('kind-of'); utils.unique = require('array-unique'); /** + * Returns true if the given value is effectively an empty string + */ + +utils.isEmptyString = function(val) { + return String(val) === '' || String(val) === './'; +}; + +/** * Returns true if the platform is windows, or `path.sep` is `\\`. * This is defined as a function to allow `path.sep` to be set in unit tests, * or by the user, if there is a reason to do so. @@ -204,11 +212,7 @@ utils.stripDrive = function(fp) { */ utils.stripPrefix = function(str) { - if (str.charAt(0) !== '.') { - return str; - } - var ch = str.charAt(1); - if (utils.isSlash(ch)) { + if (str.charAt(0) === '.' && (str.charAt(1) === '/' || str.charAt(1) === '\\')) { return str.slice(2); } return str; @@ -342,6 +346,9 @@ utils.value = function(str, unixify, options) { if (options && options.unixify === false) { return str; } + if (options && typeof options.unixify === 'function') { + return options.unixify(str); + } return unixify(str); }; @@ -353,17 +360,17 @@ utils.value = function(str, unixify, options) { */ utils.unixify = function(options) { - options = options || {}; + var opts = options || {}; return function(filepath) { - if (utils.isWindows() || options.unixify === true) { - filepath = utils.toPosixPath(filepath); - } - if (options.stripPrefix !== false) { + if (opts.stripPrefix !== false) { filepath = utils.stripPrefix(filepath); } - if (options.unescape === true) { + if (opts.unescape === true) { filepath = utils.unescape(filepath); } + if (opts.unixify === true || utils.isWindows()) { + filepath = utils.toPosixPath(filepath); + } return filepath; }; }; |