From 8cfb0ba84202d51571340dcbaf61b79d16a26c76 Mon Sep 17 00:00:00 2001 From: Elan Shanker Date: Tue, 18 Oct 2016 18:16:40 -0400 Subject: [PATCH] feat: preserve escaped brace/bracket at end of string --- index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index ca6cab4..6a18407 100644 --- a/index.js +++ b/index.js @@ -5,11 +5,12 @@ var isglob = require('is-glob'); var pathDirname = require('path-dirname'); module.exports = function globParent(str) { - // preserves full path in case of trailing path separator - str += 'a'; - // replace braces/brackets sections with * str = str.replace(/(^|[^\\])(\{([^{}]*?)}|\[([^\[\]]*?)\])/g, '$1*'); + if (/[\}\}]$/.test(str)) str += '/'; + + // preserves full path in case of trailing path separator + str += 'a'; // remove path parts that are globby do {str = pathDirname.posix(str)} while (isglob(str));