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