We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c37714a commit f759727Copy full SHA for f759727
1 file 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})`,
0 commit comments