From c19637d8403c10427421eec7838d5326cca36cbd Mon Sep 17 00:00:00 2001 From: Hans Koch Date: Thu, 25 Jul 2019 18:10:59 +0200 Subject: [PATCH 1/2] fixed parsing issues --- src/index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/index.js b/src/index.js index 82c524e..70996ff 100644 --- a/src/index.js +++ b/src/index.js @@ -64,6 +64,8 @@ function parent(str, { strict = false } = {}) { * @returns {Object} object with parsed path */ function globalyzer(pattern, opts = {}) { + if (pattern.startsWith('./')) pattern = pattern.substr(2); + let base = parent(pattern, opts); let isGlob = isglob(pattern, opts); let glob; From 1f06aeade0d57f496f376fb7f3bcd3732586aa61 Mon Sep 17 00:00:00 2001 From: Hans Koch Date: Thu, 25 Jul 2019 18:16:10 +0200 Subject: [PATCH 2/2] added resolve for ../ within paths --- src/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 70996ff..51c0316 100644 --- a/src/index.js +++ b/src/index.js @@ -40,7 +40,7 @@ function isglob(str, { strict = true } = {}) { * @returns {String} static path section of glob */ function parent(str, { strict = false } = {}) { - str = path.normalize(str).replace(/\/|\\/, '/'); + str = path.posix.normalize(str); // special case for strings ending in enclosure containing path separator if (/[\{\[].*[\/]*.*[\}\]]$/.test(str)) str += '/'; @@ -73,6 +73,8 @@ function globalyzer(pattern, opts = {}) { if (base != '.') { glob = pattern.substr(base.length); if (glob.startsWith('/')) glob = glob.substr(1); + // resolve `../` withing paths + glob = path.posix.normalize(glob) } else { glob = pattern; }