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