Skip to content

Commit 8cfb0ba

Browse files
es128phated
authored andcommitted
feat: preserve escaped brace/bracket at end of string
1 parent f2a91d1 commit 8cfb0ba

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

index.js

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

77
module.exports = function globParent(str) {
8-
// preserves full path in case of trailing path separator
9-
str += 'a';
10-
118
// replace braces/brackets sections with *
129
str = str.replace(/(^|[^\\])(\{([^{}]*?)}|\[([^\[\]]*?)\])/g, '$1*');
10+
if (/[\}\}]$/.test(str)) str += '/';
11+
12+
// preserves full path in case of trailing path separator
13+
str += 'a';
1314

1415
// remove path parts that are globby
1516
do {str = pathDirname.posix(str)} while (isglob(str));

0 commit comments

Comments
 (0)