@whitesev/utils 1.1.2 → 1.1.3

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.
package/dist/index.umd.js CHANGED
@@ -5,7 +5,6 @@
5
5
  })(this, (function () { 'use strict';
6
6
 
7
7
  class ColorConversion {
8
- constructor() { }
9
8
  /**
10
9
  * 判断是否是16进制颜色
11
10
  * @param str
@@ -201,25 +200,23 @@
201
200
  }
202
201
  /**
203
202
  * 解码
204
- * @param {string} str
203
+ * @param str
205
204
  */
206
205
  decode(str) {
207
206
  var GBKMatcher = /%[0-9A-F]{2}%[0-9A-F]{2}/;
208
207
  var UTFMatcher = /%[0-9A-F]{2}/;
209
- var gbk = true, utf = true;
208
+ var utf = true;
209
+ let that = this;
210
210
  while (utf) {
211
- // @ts-ignore
212
- gbk = str.match(GBKMatcher);
213
- // @ts-ignore
214
- utf = str.match(UTFMatcher);
215
- // @ts-ignore
216
- if (gbk && gbk in G2Uhash) {
217
- // @ts-ignore
218
- str = str.replace(gbk, String.fromCharCode("0x" + G2Uhash[gbk]));
211
+ let gbkMatch = str.match(GBKMatcher);
212
+ let utfMatch = str.match(UTFMatcher);
213
+ utf = Boolean(utfMatch);
214
+ if (gbkMatch && gbkMatch in that.#G2Uhash) {
215
+ str = str.replace(gbkMatch, String.fromCharCode(("0x" + that.#G2Uhash[gbkMatch])));
219
216
  }
220
217
  else {
221
218
  // @ts-ignore
222
- str = str.replace(utf, decodeURIComponent(utf));
219
+ str = str.replace(utfMatch, decodeURIComponent(utfMatch));
223
220
  }
224
221
  }
225
222
  return str;