@putout/plugin-remove-useless-escape 3.0.0 → 3.1.0

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.
@@ -98,7 +98,10 @@ function isEscaped(raw) {
98
98
  if (!raw.includes('\\'))
99
99
  return false;
100
100
 
101
- if (/\\\//g.test(raw) && !/\\\\\//g.test(raw))
101
+ if (/\\\\/g.test(raw))
102
+ return false;
103
+
104
+ if (/\\\//g.test(raw))
102
105
  return true;
103
106
 
104
107
  if (raw.includes('\\+') && !raw.includes('\\\\+'))
@@ -123,11 +126,11 @@ const createEncodedRegExp = (a) => RegExp(`\\\\${a}`, 'g');
123
126
 
124
127
  function unEscape(raw) {
125
128
  raw = raw
126
- .replace(/\\'/g, `'`)
127
- .replace(/\\\//g, '/')
128
- .replace(/\\\+/g, '+')
129
+ .replaceAll('\\\'', `'`)
130
+ .replaceAll('\\/', '/')
131
+ .replaceAll('\\+', '+')
129
132
  .replace(createEncodedRegExp(`"`), '"')
130
- .replace(/\\\^/g, '^')
133
+ .replaceAll('\\^', '^')
131
134
  .replace(/(\\),/, ',');
132
135
 
133
136
  for (const emoji of match(raw)) {
@@ -139,9 +142,9 @@ function unEscape(raw) {
139
142
 
140
143
  function unescapeRegExp(raw) {
141
144
  return raw
142
- .replace(/\\:/g, ':')
143
- .replace(/\+\\\//g, '+/')
144
- .replace(/\\,/g, ',');
145
+ .replaceAll('\\:', ':')
146
+ .replaceAll('\\+\\/', '+/')
147
+ .replaceAll('\\,', ',');
145
148
  }
146
149
 
147
150
  const is = (a) => (b) => b.includes(`\\${a}`) && !b.includes(`\\\\${a}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@putout/plugin-remove-useless-escape",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "type": "commonjs",
5
5
  "author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
6
6
  "description": "putout plugin adds ability to find and remove useless escape",