@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 CHANGED
@@ -154,11 +154,11 @@ function sanitizeValue(value, allowedTags) {
154
154
  });
155
155
  return filter.process(value);
156
156
  }
157
- function htmlEntityDecode(value) {
158
- if (!value) {
159
- return "";
160
- }
161
- return value.replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&#39;/g, "'");
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(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">");
162
162
  }
163
163
 
164
164
  // src/helpers/video.ts
package/dist/index.d.cts CHANGED
@@ -6,7 +6,7 @@ type AllowedTag = Tag | {
6
6
  tag: Tag;
7
7
  attributes?: Attributes[];
8
8
  };
9
- declare function htmlEntityDecode(value?: string): string;
9
+ declare function htmlEntityDecode(str?: string): string;
10
10
 
11
11
  type TMessage = {
12
12
  message: string;
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ type AllowedTag = Tag | {
6
6
  tag: Tag;
7
7
  attributes?: Attributes[];
8
8
  };
9
- declare function htmlEntityDecode(value?: string): string;
9
+ declare function htmlEntityDecode(str?: string): string;
10
10
 
11
11
  type TMessage = {
12
12
  message: string;
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(value) {
120
- if (!value) {
121
- return "";
122
- }
123
- return value.replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&#39;/g, "'");
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(/&amp;/g, "&").replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&lt;/g, "<").replace(/&gt;/g, ">");
124
124
  }
125
125
 
126
126
  // src/helpers/video.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@excofy/utils",
3
- "version": "2.3.1",
3
+ "version": "2.3.2",
4
4
  "description": "Biblioteca de utilitários para o Excofy",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -101,15 +101,15 @@ export function sanitizeValue(
101
101
  return filter.process(value);
102
102
  }
103
103
 
104
- export function htmlEntityDecode(value?: string): string {
105
- if (!value) {
106
- return '';
107
- }
108
-
109
- return value
110
- .replace(/&gt;/g, '>')
111
- .replace(/&lt;/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(/&amp;/g, '&')
113
111
  .replace(/&quot;/g, '"')
114
- .replace(/&#39;/g, "'");
112
+ .replace(/&apos;/g, "'")
113
+ .replace(/&lt;/g, '<')
114
+ .replace(/&gt;/g, '>');
115
115
  }