nuxt-og-image 2.0.0-beta.5 → 2.0.0-beta.7
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/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -164,11 +164,15 @@ function getBodyJson(req) {
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
|
|
167
|
-
function
|
|
167
|
+
function decodeHtml(html) {
|
|
168
|
+
return html.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/¢/g, "\xA2").replace(/£/g, "\xA3").replace(/¥/g, "\xA5").replace(/€/g, "\u20AC").replace(/©/g, "\xA9").replace(/®/g, "\xAE").replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'").replace(///g, "/").replace(/&#([0-9]+);/g, (full, int) => {
|
|
169
|
+
return String.fromCharCode(parseInt(int));
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function decodeObjectHtmlEntities(obj) {
|
|
168
173
|
Object.entries(obj).forEach(([key, value]) => {
|
|
169
|
-
if (typeof value === "string")
|
|
170
|
-
obj[key] = value
|
|
171
|
-
}
|
|
174
|
+
if (typeof value === "string")
|
|
175
|
+
obj[key] = decodeHtml(value);
|
|
172
176
|
});
|
|
173
177
|
return obj;
|
|
174
178
|
}
|
|
@@ -192,7 +196,7 @@ function extractOgImageOptions(html) {
|
|
|
192
196
|
else
|
|
193
197
|
options.description = html.match(/<meta name="description" content="(.*?)">/)?.[1];
|
|
194
198
|
}
|
|
195
|
-
return
|
|
199
|
+
return decodeObjectHtmlEntities(options);
|
|
196
200
|
}
|
|
197
201
|
return false;
|
|
198
202
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { defineSatoriTransformer } from "../utils.mjs";
|
|
2
|
+
import { decodeHtml } from "../../../utils-pure.mjs";
|
|
2
3
|
export default defineSatoriTransformer(() => {
|
|
3
4
|
return {
|
|
4
5
|
filter: (node) => typeof node.props?.children === "string",
|
|
5
6
|
transform: async (node) => {
|
|
6
|
-
node.props.children = node.props.children
|
|
7
|
+
node.props.children = decodeHtml(node.props.children);
|
|
7
8
|
}
|
|
8
9
|
};
|
|
9
10
|
});
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
function
|
|
1
|
+
export function decodeHtml(html) {
|
|
2
|
+
return html.replace(/</g, "<").replace(/>/g, ">").replace(/&/g, "&").replace(/¢/g, "\xA2").replace(/£/g, "\xA3").replace(/¥/g, "\xA5").replace(/€/g, "\u20AC").replace(/©/g, "\xA9").replace(/®/g, "\xAE").replace(/"/g, '"').replace(/'/g, "'").replace(/'/g, "'").replace(///g, "/").replace(/&#([0-9]+);/g, (full, int) => {
|
|
3
|
+
return String.fromCharCode(parseInt(int));
|
|
4
|
+
});
|
|
5
|
+
}
|
|
6
|
+
function decodeObjectHtmlEntities(obj) {
|
|
2
7
|
Object.entries(obj).forEach(([key, value]) => {
|
|
3
|
-
if (typeof value === "string")
|
|
4
|
-
obj[key] = value
|
|
5
|
-
}
|
|
8
|
+
if (typeof value === "string")
|
|
9
|
+
obj[key] = decodeHtml(value);
|
|
6
10
|
});
|
|
7
11
|
return obj;
|
|
8
12
|
}
|
|
@@ -26,7 +30,7 @@ export function extractOgImageOptions(html) {
|
|
|
26
30
|
else
|
|
27
31
|
options.description = html.match(/<meta name="description" content="(.*?)">/)?.[1];
|
|
28
32
|
}
|
|
29
|
-
return
|
|
33
|
+
return decodeObjectHtmlEntities(options);
|
|
30
34
|
}
|
|
31
35
|
return false;
|
|
32
36
|
}
|