Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.

Commit 76274d2

Browse files
committed
fix
1 parent 0d55d33 commit 76274d2

File tree

1 file changed

+0
-31
lines changed

1 file changed

+0
-31
lines changed

index.js

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,6 @@ const web = express()
1414
web.use(compress({ level: 1 }))
1515

1616
// Main
17-
web.use((req, res, next) => {
18-
// Check if the response is HTML
19-
if (res.getHeader('Content-Type') && res.getHeader('Content-Type').includes('text/html')) {
20-
// Define the meta tags
21-
const metaTags = `
22-
<link rel="icon" href="/favicon.png">
23-
<meta property="og:title" content="CSPI Unrestricted">
24-
<meta property="og:description" content="Unrestricted information about CSPI.">
25-
<meta name="theme-color" content="#232425">
26-
`;
27-
28-
// Function to inject the meta tags into the response
29-
const injectMetaTags = (body) => {
30-
// Look for the </head> tag in the HTML response and inject the meta tags before it
31-
return body.replace('<link rel="icon" sizes="96x96" href="https://publish-01.obsidian.md/access/f786db9fac45774fa4f0d8112e232d67/favicon-96x96.png">', metaTags);
32-
};
33-
34-
// Wrap the res.send method to intercept the response and inject the meta tags
35-
const originalSend = res.send;
36-
res.send = function (body) {
37-
if (body && typeof body === 'string') {
38-
// If the response body is a string, inject the meta tags
39-
body = injectMetaTags(body);
40-
}
41-
originalSend.call(this, body);
42-
};
43-
}
44-
45-
next();
46-
});
47-
4817
web.use(express.static(path.join(__dirname, "public")))
4918
web.use("*", (req, res)=>res.redirect("/"))
5019
web.listen(port, ()=>{console.log(`Server is running. Port: ${port}`)})

0 commit comments

Comments
 (0)