@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.amd.js +9 -12
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +9 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +9 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +9 -12
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +9 -12
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +9 -12
- package/dist/index.umd.js.map +1 -1
- package/dist/src/ColorConversion.d.ts +0 -1
- package/dist/src/GBKEncoder.d.ts +1 -1
- package/package.json +1 -1
- package/src/ColorConversion.ts +0 -1
- package/src/GBKEncoder.ts +16 -14
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
|
|
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
|
|
202
|
+
var utf = true;
|
|
203
|
+
let that = this;
|
|
204
204
|
while (utf) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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(
|
|
213
|
+
str = str.replace(utfMatch, decodeURIComponent(utfMatch));
|
|
217
214
|
}
|
|
218
215
|
}
|
|
219
216
|
return str;
|