nuxt-og-image 2.0.0-beta.6 → 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,13 +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
|
-
return String.fromCharCode(parseInt(int));
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
+
if (typeof value === "string")
|
|
175
|
+
obj[key] = decodeHtml(value);
|
|
174
176
|
});
|
|
175
177
|
return obj;
|
|
176
178
|
}
|
|
@@ -194,7 +196,7 @@ function extractOgImageOptions(html) {
|
|
|
194
196
|
else
|
|
195
197
|
options.description = html.match(/<meta name="description" content="(.*?)">/)?.[1];
|
|
196
198
|
}
|
|
197
|
-
return
|
|
199
|
+
return decodeObjectHtmlEntities(options);
|
|
198
200
|
}
|
|
199
201
|
return false;
|
|
200
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,10 +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
|
-
return String.fromCharCode(parseInt(int));
|
|
6
|
-
});
|
|
7
|
-
}
|
|
8
|
+
if (typeof value === "string")
|
|
9
|
+
obj[key] = decodeHtml(value);
|
|
8
10
|
});
|
|
9
11
|
return obj;
|
|
10
12
|
}
|
|
@@ -28,7 +30,7 @@ export function extractOgImageOptions(html) {
|
|
|
28
30
|
else
|
|
29
31
|
options.description = html.match(/<meta name="description" content="(.*?)">/)?.[1];
|
|
30
32
|
}
|
|
31
|
-
return
|
|
33
|
+
return decodeObjectHtmlEntities(options);
|
|
32
34
|
}
|
|
33
35
|
return false;
|
|
34
36
|
}
|