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