@excofy/utils 2.3.2 → 2.3.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.cjs +3 -0
- package/dist/index.js +3 -0
- package/package.json +1 -1
- package/src/helpers/sanitize.ts +4 -0
package/dist/index.cjs
CHANGED
|
@@ -155,6 +155,9 @@ function sanitizeValue(value, allowedTags) {
|
|
|
155
155
|
return filter.process(value);
|
|
156
156
|
}
|
|
157
157
|
function htmlEntityDecode(str = "") {
|
|
158
|
+
if (!str || typeof str !== "string" || str.length === 0) {
|
|
159
|
+
return "";
|
|
160
|
+
}
|
|
158
161
|
return str.replace(/&#(\d+);/g, (_, code) => String.fromCharCode(code)).replace(
|
|
159
162
|
/&#x([0-9a-f]+);/gi,
|
|
160
163
|
(_, code) => String.fromCharCode(Number.parseInt(code, 16))
|
package/dist/index.js
CHANGED
|
@@ -117,6 +117,9 @@ function sanitizeValue(value, allowedTags) {
|
|
|
117
117
|
return filter.process(value);
|
|
118
118
|
}
|
|
119
119
|
function htmlEntityDecode(str = "") {
|
|
120
|
+
if (!str || typeof str !== "string" || str.length === 0) {
|
|
121
|
+
return "";
|
|
122
|
+
}
|
|
120
123
|
return str.replace(/&#(\d+);/g, (_, code) => String.fromCharCode(code)).replace(
|
|
121
124
|
/&#x([0-9a-f]+);/gi,
|
|
122
125
|
(_, code) => String.fromCharCode(Number.parseInt(code, 16))
|
package/package.json
CHANGED
package/src/helpers/sanitize.ts
CHANGED
|
@@ -102,6 +102,10 @@ export function sanitizeValue(
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
export function htmlEntityDecode(str = ''): string {
|
|
105
|
+
if (!str || typeof str !== 'string' || str.length === 0) {
|
|
106
|
+
return '';
|
|
107
|
+
}
|
|
108
|
+
|
|
105
109
|
return str
|
|
106
110
|
.replace(/&#(\d+);/g, (_, code) => String.fromCharCode(code))
|
|
107
111
|
.replace(/&#x([0-9a-f]+);/gi, (_, code) =>
|