brace-expansion 3.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.js +21 -11
  2. package/package.json +1 -1
  3. package/tea.yaml +6 -0
package/index.js CHANGED
@@ -5,6 +5,16 @@ const escOpen = '\0OPEN' + Math.random() + '\0'
5
5
  const escClose = '\0CLOSE' + Math.random() + '\0'
6
6
  const escComma = '\0COMMA' + Math.random() + '\0'
7
7
  const escPeriod = '\0PERIOD' + Math.random() + '\0'
8
+ const escSlashPattern = new RegExp(escSlash, 'g')
9
+ const escOpenPattern = new RegExp(escOpen, 'g')
10
+ const escClosePattern = new RegExp(escClose, 'g')
11
+ const escCommaPattern = new RegExp(escComma, 'g')
12
+ const escPeriodPattern = new RegExp(escPeriod, 'g')
13
+ const slashPattern = /\\\\/g
14
+ const openPattern = /\\{/g
15
+ const closePattern = /\\}/g
16
+ const commaPattern = /\\,/g
17
+ const periodPattern = /\\./g
8
18
 
9
19
  /**
10
20
  * @return {number}
@@ -19,22 +29,22 @@ function numeric (str) {
19
29
  * @param {string} str
20
30
  */
21
31
  function escapeBraces (str) {
22
- return str.split('\\\\').join(escSlash)
23
- .split('\\{').join(escOpen)
24
- .split('\\}').join(escClose)
25
- .split('\\,').join(escComma)
26
- .split('\\.').join(escPeriod)
32
+ return str.replace(slashPattern, escSlash)
33
+ .replace(openPattern, escOpen)
34
+ .replace(closePattern, escClose)
35
+ .replace(commaPattern, escComma)
36
+ .replace(periodPattern, escPeriod)
27
37
  }
28
38
 
29
39
  /**
30
40
  * @param {string} str
31
41
  */
32
42
  function unescapeBraces (str) {
33
- return str.split(escSlash).join('\\')
34
- .split(escOpen).join('{')
35
- .split(escClose).join('}')
36
- .split(escComma).join(',')
37
- .split(escPeriod).join('.')
43
+ return str.replace(escSlashPattern, '\\')
44
+ .replace(escOpenPattern, '{')
45
+ .replace(escClosePattern, '}')
46
+ .replace(escCommaPattern, ',')
47
+ .replace(escPeriodPattern, '.')
38
48
  }
39
49
 
40
50
  /**
@@ -144,7 +154,7 @@ function expand (str, isTop) {
144
154
  const isOptions = m.body.indexOf(',') >= 0
145
155
  if (!isSequence && !isOptions) {
146
156
  // {a},b}
147
- if (m.post.match(/,.*\}/)) {
157
+ if (m.post.match(/,(?!,).*\}/)) {
148
158
  str = m.pre + '{' + m.body + escClose + m.post
149
159
  return expand(str)
150
160
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "brace-expansion",
3
3
  "description": "Brace expansion as known from sh/bash",
4
- "version": "3.0.0",
4
+ "version": "4.0.1",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git://github.com/juliangruber/brace-expansion.git"
package/tea.yaml ADDED
@@ -0,0 +1,6 @@
1
+ # https://tea.xyz/what-is-this-file
2
+ ---
3
+ version: 1.0.0
4
+ codeOwners:
5
+ - '0xE7DEE1B8Bb97C3065850Cf582D6DED57C6009587'
6
+ quorum: 1