We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents b4d3261 + d2a70f0 commit 77b9c0eCopy full SHA for 77b9c0e
2 files changed
index.js
@@ -8,9 +8,10 @@ const port = process.env.PORT || 9000;
8
9
function htmlToMf2(url, html, res) {
10
mf2.get({ baseUrl: url, html }, (err, data) => {
11
+ const body = err || data;
12
res
13
.header("content-type", "application/json; charset=UTF-8")
- .send(JSON.stringify(err || data, null, 2));
14
+ .send(JSON.stringify(body, null, 2));
15
});
16
}
17
@@ -19,8 +20,16 @@ app.use(express.static("public"));
19
20
app.get("/", async (req, res) => {
21
if (req.query.url) {
22
const url = req.query.url;
- const { body } = await undici.request(url);
23
- htmlToMf2(url, body.text(), res);
+ const { body } = await undici.request(url, {
24
+ maxRedirections: 2,
25
+ headers: {
26
+ accept: "text/html, text/mf2+html",
27
+ },
28
+ method: "GET",
29
+ });
30
+ const text = await body.text();
31
+ console.log(text);
32
+ htmlToMf2(url, text, res);
33
} else {
34
res.render("index.html.ejs", {
35
version: `${pkg.version} (lib: ${mf2.version})`,
package.json
@@ -1,7 +1,7 @@
1
{
2
"name": "microformats-website-node",
3
"description": "A website written using Node to demonstrate Microformats2 usage",
4
- "version": "1.0.3",
+ "version": "1.0.4",
5
"engines": {
6
"node": "17.x",
7
"yarn": "1.x"
0 commit comments