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