aboutsummaryrefslogtreecommitdiff
path: root/node_modules/nanomatch/lib/utils.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/nanomatch/lib/utils.js')
-rw-r--r--node_modules/nanomatch/lib/utils.js29
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;
};
};