Skip to content

Commit

Permalink
feat: preserve escaped brace/bracket at end of string
Browse files Browse the repository at this point in the history
  • Loading branch information
es128 authored and phated committed Jan 27, 2021
1 parent f2a91d1 commit 8cfb0ba
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 8cfb0ba

Please sign in to comment.