@bhsd/common 0.6.0 → 0.6.2
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.d.ts +1 -1
- package/dist/index.js +8 -8
- package/dist/index.mjs +8 -8
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -30,18 +30,18 @@ __export(src_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(src_exports);
|
|
32
32
|
const CDN = "https://testingcf.jsdelivr.net";
|
|
33
|
-
let
|
|
33
|
+
let textarea;
|
|
34
34
|
if (typeof document === "object") {
|
|
35
|
-
|
|
35
|
+
textarea = document.createElement("textarea");
|
|
36
36
|
}
|
|
37
|
+
const decodeHTML = (str) => {
|
|
38
|
+
textarea.innerHTML = str;
|
|
39
|
+
return textarea.value;
|
|
40
|
+
};
|
|
37
41
|
const rawurldecode = (str) => decodeURIComponent(str.replace(/%(?![\da-f]{2})/giu, "%25"));
|
|
38
42
|
const normalizeTitle = (title) => {
|
|
39
43
|
const decoded = rawurldecode(title);
|
|
40
|
-
|
|
41
|
-
return decoded;
|
|
42
|
-
}
|
|
43
|
-
span.innerHTML = decoded;
|
|
44
|
-
return span.textContent;
|
|
44
|
+
return /[<>[\]|{}]/u.test(decoded) ? decoded : decodeHTML(decoded);
|
|
45
45
|
};
|
|
46
46
|
const numToHex = (d) => Math.round(d * 255).toString(16).padStart(2, "0");
|
|
47
47
|
const splitColors = (str, hsl = true) => {
|
|
@@ -54,7 +54,7 @@ const splitColors = (str, hsl = true) => {
|
|
|
54
54
|
pieces.push([str.slice(lastIndex, index), lastIndex, index, false]);
|
|
55
55
|
}
|
|
56
56
|
({ lastIndex } = re);
|
|
57
|
-
pieces.push([mt[2], index, lastIndex,
|
|
57
|
+
pieces.push([mt[2], index, lastIndex, str.charAt(index - 1) !== "&" || !/^#\d+$/u.test(mt[2])]);
|
|
58
58
|
mt = re.exec(str);
|
|
59
59
|
}
|
|
60
60
|
if (str.length > lastIndex) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const CDN = "https://testingcf.jsdelivr.net";
|
|
2
|
-
let
|
|
2
|
+
let textarea;
|
|
3
3
|
if (typeof document === "object") {
|
|
4
|
-
|
|
4
|
+
textarea = document.createElement("textarea");
|
|
5
5
|
}
|
|
6
|
+
const decodeHTML = (str) => {
|
|
7
|
+
textarea.innerHTML = str;
|
|
8
|
+
return textarea.value;
|
|
9
|
+
};
|
|
6
10
|
const rawurldecode = (str) => decodeURIComponent(str.replace(/%(?![\da-f]{2})/giu, "%25"));
|
|
7
11
|
const normalizeTitle = (title) => {
|
|
8
12
|
const decoded = rawurldecode(title);
|
|
9
|
-
|
|
10
|
-
return decoded;
|
|
11
|
-
}
|
|
12
|
-
span.innerHTML = decoded;
|
|
13
|
-
return span.textContent;
|
|
13
|
+
return /[<>[\]|{}]/u.test(decoded) ? decoded : decodeHTML(decoded);
|
|
14
14
|
};
|
|
15
15
|
const numToHex = (d) => Math.round(d * 255).toString(16).padStart(2, "0");
|
|
16
16
|
const splitColors = (str, hsl = true) => {
|
|
@@ -23,7 +23,7 @@ const splitColors = (str, hsl = true) => {
|
|
|
23
23
|
pieces.push([str.slice(lastIndex, index), lastIndex, index, false]);
|
|
24
24
|
}
|
|
25
25
|
({ lastIndex } = re);
|
|
26
|
-
pieces.push([mt[2], index, lastIndex,
|
|
26
|
+
pieces.push([mt[2], index, lastIndex, str.charAt(index - 1) !== "&" || !/^#\d+$/u.test(mt[2])]);
|
|
27
27
|
mt = re.exec(str);
|
|
28
28
|
}
|
|
29
29
|
if (str.length > lastIndex) {
|