Skip to content

Commit 8269bd8

Browse files
es128phated
authored andcommitted
feat: new approach to braces/brackets handling
1 parent fadb8f5 commit 8269bd8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ var isglob = require('is-glob');
55
var pathDirname = require('path-dirname');
66

77
module.exports = function globParent(str) {
8-
// replace braces/brackets sections with *
9-
str = str.replace(/(^|[^\\])(\{([^{}]*?)}|\[([^\[\]]*?)\])/g, '$1*');
10-
if (/[\}\]]$/.test(str)) str += '/';
8+
// special case for strings ending in enclosure containing path separator
9+
if (/[\{\[].*[\/]*.*[\}\]]$/.test(str)) str += '/';
1110

1211
// preserves full path in case of trailing path separator
1312
str += 'a';
1413

1514
// remove path parts that are globby
16-
do {str = pathDirname.posix(str)} while (isglob(str));
15+
do {str = pathDirname.posix(str)}
16+
while (isglob(str) || /(^|[^\\])[\{\[]/.test(str));
1717

1818
// remove escape chars and return result
1919
return str.replace(/\\([\*\?\|\[\]\(\)\{\}])/g, '$1');

0 commit comments

Comments
 (0)