File tree Expand file tree Collapse file tree 3 files changed +370
-25
lines changed Expand file tree Collapse file tree 3 files changed +370
-25
lines changed Original file line number Diff line number Diff line change 11const express = require ( "express" ) ;
22const { mf2 } = require ( "microformats-parser" ) ;
3- const undici = require ( "undici" ) ;
43const pkg = require ( "./package.json" ) ;
54const app = express ( ) ;
65const port = process . env . PORT || 9000 ;
@@ -36,15 +35,15 @@ app.use(express.static("public"));
3635app . get ( "/" , async ( req , res ) => {
3736 if ( req . query . url ) {
3837 const url = req . query . url ;
39- const { body } = await undici . request ( url , {
40- maxRedirections : 2 ,
38+ await fetch ( url , {
4139 headers : {
4240 accept : "text/html, text/mf2+html" ,
4341 } ,
4442 method : "GET" ,
43+ } ) . then ( async ( response ) => {
44+ const html = await response . text ( ) ;
45+ htmlToMf2 ( url , html , res ) ;
4546 } ) ;
46- const text = await body . text ( ) ;
47- htmlToMf2 ( url , text , res ) ;
4847 } else {
4948 res . render ( "index.html.ejs" , {
5049 version : `${ pkg . version } (lib: ${ mf2version } )` ,
Original file line number Diff line number Diff line change 88 "yarn" : " 1.x"
99 },
1010 "scripts" : {
11- "start" : " node index.js"
11+ "start" : " node index.js" ,
12+ "prepare" : " husky install"
1213 },
1314 "dependencies" : {
1415 "@yarnpkg/lockfile" : " ^1.1.0" ,
1516 "ejs" : " ^3.1.8" ,
1617 "express" : " ^4.18.1" ,
17- "microformats-parser" : " ^1.5.2" ,
18- "undici" : " ^5.6.1"
18+ "microformats-parser" : " ^1.5.2"
19+ },
20+ "devDependencies" : {
21+ "husky" : " >=6" ,
22+ "lint-staged" : " >=10" ,
23+ "prettier" : " ^3.0.3"
24+ },
25+ "lint-staged" : {
26+ "*.{js,css,md}" : " prettier --write"
1927 }
2028}
You can’t perform that action at this time.
0 commit comments